Release, Superstrict help needs work.

BlitzMax Forums/BlitzMax Beginners Area/Release, Superstrict help needs work.

sswift(Posted 2006) [#1]
I'm trying to find the answers to this stuff myself, really I am, but...


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
GCCollect
print MemAlloced()
print a

b:MyType=new MyType
print MemAlloced()

Release b
GCCollect
Print MemAlloced()




This help file entry is very broken. MemAlloced() does not exist, and when replaced with GCMemAlloced() it still won't compile because B is not an integer and it errors on Release B.

I changed B to an int and then got rid of the release command and replaced it with b=0 to see what the compiler would do, and it did not free the memory. Not particularly surprising.

But it concerns me that one can that easily assign a type to an int, and it will not be freed, and no compile error will be generated, when one attempts to assign Null to it.

However, Strict to the rescue, right?

I also noticed when when looking to see how to use Strict, that SuperStrict doesn't have a description in the help file! Luckilly the BlitzWiki has a description.


klepto2(Posted 2006) [#2]
You only have to make this instead of Release B :

b = null


with making b = Null you delete every reference to the object and it will be collected by the Garbage Collector.


sswift(Posted 2006) [#3]
klepto:
Yes, I'm aware of that.


Yan(Posted 2006) [#4]
Have you read this Swift?...
http://www.blitzwiki.org/index.php/Memory_management

It's a bit out of date where FlushMem() and MemAlloced() are concerned but it's still valid.


sswift(Posted 2006) [#5]
What do you mean a bit out of date? I know the memalloced thing is gone, but what about flushmem?


Yan(Posted 2006) [#6]
Those articles were written before automatic garbage collection was implemented. In version 1.12 and above, Flushmem() no longer exists.

The old manual GC *required* you to use Flushmem() to clean up.

The new GC will (by default) automatically clean up for you, but you can call it manually if you wish with GCCollect().


FlameDuck(Posted 2006) [#7]
Just don't use Integer handles.