About memory freeing ?
BlitzMax Forums/BlitzMax Programming/About memory freeing ?
| ||
Hi :) I have try to compress a bank :) the code work but i don't understand why my memory is not free after process ? the output window return Executing:Zip Engine.exe MEM USED 1 : 15917 / 16656 MEM USED 2 : 1447823 / 1448195 MEM USED 3 : 90692 / 95558 Process complete Theoretically the test number 3 should be the same one as the test number 1 because i released my RAM? or i'm idiot ? This is the code used for my test : |
| ||
Building test Compiling:test.bmx flat assembler version 1.51 3 passes, 3877 bytes. Linking:test.exe Executing:test.exe MEM USED 1 : 15897 / 16656 MEM USED 2 : 952484 / 952927 MEM USED 3 : 29097 / 29887 Process complete |
| ||
I don't understand why my memory is not free after process ? Because you aren't dereferenceing your banks, ie they still exsist as valid objects, and so aren't being garbagecollected.Try this code instead: Import Pub.ZLib FlushMem Print "MEM USED 1 : "+MemAlloced()+" / "+MemUsage() Local MySourceBank:TBank=TBank.load("C:\Dev\42ninjas\bin\logo.png") Print "MEM USED 2 : "+MemAlloced()+" / "+MemUsage() Local MyOutBank:TBank=CompressBank(MySourceBank) MyOutBank.Save("C:\Dev\logo.bin") MyOutBank = Null MySourceBank = Null FlushMem Print "MEM USED 3 : "+MemAlloced()+" / "+MemUsage() EndOh and I leave you with this quote from the manual: Function MemFree( mem:Byte Ptr,size ) Free allocated memory. The memory specified by mem must have been previously allocated by MemAlloc or MemExtend. |
| ||
Ok ok !! many thanks FlameDuck ! |