Question on memory allocation

BlitzMax Forums/BlitzMax Beginners Area/Question on memory allocation

rod54(Posted 2005) [#1]
Can someone explain why memory does not get released
for b in example below.

Rem
Release removes the internal reference caused by creating an integer handle to a type.
End Rem

Type MyType
field bigmap[1024*1024]
End Type

a=new MyType
Print MemAlloced()

release a
FlushMem
Print MemAlloced()
Print a

b:MyType=new MyType
Print MemAlloced()

release b
FlushMem
Print MemAlloced()

output:
Executing:Release.exe
4207424
8932
0
4203367
4203272


Who was John Galt?(Posted 2005) [#2]
Some memory is used in linking an integer handle to a type - release frees the memory used for that. I guess when you release the handle, you have cleared the only reference to to mytype it points to, so that can be freed too on the next flushmem. b is of type mytype - no integer handle - so no handle memory to reclaim. To free the memory pointed to by b, set b=Null and Flushmem.


Eric(Posted 2005) [#3]
http://www.blitzbasic.com/Community/posts.php?topic=44911

This will help


rod54(Posted 2005) [#4]
thanks for the info...