LoadSound & Ram

BlitzMax Forums/BlitzMax Beginners Area/LoadSound & Ram

degac(Posted 2006) [#1]
Hi
I have a little problem (and maybe the solution too...):
in the game I'm writing I have a problem 'Error: out of memory' when I CHANGE the music track.
The music track is loaded ONCE at the start of the game, it plays perfectly but when I change the level I change track and I get the error...

Cause (perhaps..)

The tracks have a different duration so I think they take different amount of ram (right?) and while the first loading is OK the second rises the error because there are not enough free ram to expand the .ogg file.

PS: I'm writing the game to run on 128 Mb (and this is the ONLY - at the moment! - problem that I must resolve).

Solution:
make ALL the tracks of the same duration means same amount of RAM when 'decompressed'?
In the program I use

sound_background:tsound=LoadSound(...)
...
at the change of level

sound_background=NULL ' <--- it is useful?
sound_background=LoadSound(Next track...)

Thanks in advance for any answers/solution!


Ghost Dancer(Posted 2006) [#2]
It shouldn't matter if your tracks are different lengths, but just make sure you free up the old track before loading the new one.

after your line "sound_background=NULL", it is best to run the garbage collector to make sure the memory is freed up (setting it to NULL just means it will be cleared the next time the collector runs) - you can manually run the garbage collector with the GCCollect() function.

Once that memory has been freed up, you should be able to load in your next track without any problems


degac(Posted 2006) [#3]
Ok - thanks - I was already programmed a 'test with GCcollect()'...