4096 channel limit - unable to clear channels
BlitzMax Forums/BlitzMax Programming/4096 channel limit - unable to clear channels
| ||
Please can you test this code and see if you can see where I've gone wrong, thanks! Basically at loop iteration 4096 when 4095 channels have been allocated and supposedly freed with StopChannel() it bombs with "attempt to access field or method of null object) on the StopChannel line. This is because the channel is null because AllocChannel starts returning null after channel 4096. The limit is not the issue here, that's fine, the issue is why aren't they freeing up? I'm running 1.24. Syncmoded a few months back (after Mark's new DX7 rewrite) but not since. For Local i=1 To 5000 Local c:TChannel = AllocChannel() StopChannel(c) c=null GCCollect 'safety Print i Next This has probably meant that my games bombs if you play them long enough. :-( |
| ||
It sounds like a bug to me... |
| ||
nothing wrong with the memory i.e. it appears to be freed:GCCollect 'safety For Local i=1 To 5000 GCCollect() 'safety Local before = GCMemAlloced() Local c:TChannel = AllocChannel() GCCollect() 'safety Local after = GCMemAlloced() StopChannel(c) c=Null GCCollect() 'safety Local freed = GCMemAlloced() Print i + " before:"+before+" after:"+after+" freed:"+freed Next |
| ||
It works OK for me and I'm fully up-to-date with syncmods. |
| ||
Works for me too...fully sync'd. Have you sync'd up with any of the sound changes that Mark and Skid did a few months back? I know there was a 4096 channel bug then that was fixed. |
| ||
this ? |
| ||
OK thanks. I'll sync mods and see what happens. |
| ||
Fine now. thanks. So the moral of the story is always syncmods before reporting possible bugs. |
| ||
there is another problem with this code. Local do not need to be freed within the scope or are at least not guaranteed to do so ... so this test, even before the sync, does not needfully show the real state unless you put the local within another scope which it has to leave. |
| ||
so even after making it null and calling GCCollect? |
| ||
At least from what stated. Local are local to a scope and until that scope is left, the GC does not directly handle them. Thats why you should never use locals on application level as they are not fully GC bound and do not show up in the GCMemAlloced for example. |
| ||
Local are local to a scope and until that scope is left, the GC does not directly handle them. Sure you must be right but where do you get that information from? Using this you can see objects and memory being released each gccollect bbGCSetDebug(1) For Local i=1 To 5000 Local c:TChannel = AllocChannel() StopChannel(c) c=Null ' GCCollect 'safety Print GCMemAlloced() Print i Next Extern Function bbGCSetDebug(mode:Int) EndExtern |
| ||
Thats why you should never use locals on application level as they are not fully GC bound and do not show up in the GCMemAlloced for example. Ah, I'm OK as I use globals there. |