can you create memory leaks without using lists?
BlitzMax Forums/BlitzMax Programming/can you create memory leaks without using lists?
| ||
| I was wondering... |
| ||
If you want a memory leak, try this...While True MemAlloc( 2 ) Wend |
| ||
| I dont even know what that does |
| ||
| lol |
| ||
| I dont even know what that does it continuously allocates 2 bytes of memory each loop cycle until you cancel the program, but since the memory is not being freed (nor assigned to anything) it is in essence a memory leak. |
| ||
| Ok, but I dont know how to use it anyway. The question is more "if I dont use lists (arrays instead) and dont use "alloc", do I possibly risk memory leaks or I'm completely safe?" |
| ||
| You're fine if the data is referenced 'normally'. I'd guess that means not by a pointer (other than Object). |
| ||
IMHO opinion the most insidious source of memory leaks in BlitzMax is when you happen to create circular references. The simplest example of it being:Type SomeType
Field bla:SomeType
End Type
Repeat
t:SomeType = New SomeType
t.bla = t
FlushMem
ForeverHere you get a memory leak because none of the created objects will ever be released, even though you call FlushMem continously and the objects are not referenced anymore.At least, this is documented. |