About memory freeing ?

BlitzMax Forums/BlitzMax Programming/About memory freeing ?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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 :

Import Pub.ZLib

Print "MEM USED 1 : "+MemAlloced()+" / "+MemUsage()
MySourceBank:TBank=TBank.load("C:\Filou\editor.jpg") 
Print "MEM USED 2 : "+MemAlloced()+" / "+MemUsage()
MyOutBank:TBank=CompressBank(MySourceBank)
MyOutBank.Save("C:\Filou\editor.bin") 

MemFree(MyOutBank,BankSize(MyOutBank))
FlushMem

MemFree(MySourceBank,BankSize(MySourceBank))
FlushMem

Print "MEM USED 3 : "+MemAlloced()+" / "+MemUsage()
End

Function CompressBank:TBank(Bank:TBank)
	Local size=bank.Size()
	Local out_size=size+size/10+32
	Local out:TBank=TBank.Create( out_size )
	compress out.Buf()+4,out_size,bank.Buf(),size
	out.PokeByte 0,size
	out.PokeByte 1,size Shr 8
	out.PokeByte 2,size Shr 16
	out.PokeByte 3,size Shr 24
	out.Resize out_size+4
	Return out
End Function

Function UncompressBank:TBank(Bank:TBank)
	Local out_size
	out_size:|bank.PeekByte(0)
	out_size:|bank.PeekByte(1) Shl 8
	out_size:|bank.PeekByte(2) Shl 16
	out_size:|bank.PeekByte(3) Shl 24
	Local out:TBank=TBank.Create( out_size )
	uncompress out.Buf(),out_size,bank.Buf()+4,bank.Size()-4
	Return out
End Function