Memory leak?[Solved]

When you loop a level(with music,ogg format),you'll find RAM occupied by OpenBOR is always increasing(by about 100K every time).
I guess OpenBOR fails to release the music buffer when a level ends.
I'm working on an ARPG Mod and the level is repeated played.
This problem is serious to me.
Can someone fix it?
Thanks.

Edit:Finally worked it out. Engine bug...
 
Well, I found the problem has something to do with the function
ov_open_callbacks()
in soundmix.c.

Each time when calling the function, a memory leak happens even ov_clear() is called before it...

 
Odd. I'll have a look when I can. Thanks for the catch - and looking deeper. let me know if you find any other clues.

DC
 
Thanks for the reply. DC.

I found another problem in soundmix.c

----------------------------------------------------------------
int sound_open_ogg(char *filename, char *packname, int volume, int loop, u32 music_offset)
{
...
for(i = 0; i < MUSIC_NUM_BUFFERS; i++)
{
    musicchannel.buf = malloc(MUSIC_BUF_SIZE * sizeof(short));
    if(musicchannel.buf == NULL)
    {
        sound_close_ogg();
#ifdef VERBOSE
        printf("buf is null\n");
#endif
        goto error_exit;
    }
    memset(musicchannel.buf, 0, MUSIC_BUF_SIZE * sizeof(short));
}
...
}

-----------------------------------------------------------

I think musicchannel.buf is failed to free.

But this is not the key problem.
The key problem is still in ov_open_callbacks().
I don't know weather it's a bug with ogg playback library and I can do nothing to it.

I'm not good at C and I don't know if I'm right.
I just tell what I found.
I really hope this problem could be solved and it's a really serious one.

Edit:
This bug is very easy to reproduce.

Anim idle
loop 1
delay 5
@cmd playmusic "data/music/test.ogg" #Memory leak, Memory usage boosts!!
#@cmd playmusic "data/music/test.bor" #No memory leak
frame none
frame none

 
Judging by that, i think when the support for OGG was done, something broke up that caused the memory leak.

DC, what kind of library was used for OGG, is it standard or just adapted from the OGG specs? I know that OpenBOR's a product of many people plastering features to features, so I don't know if you got the answer to that I think. And i hope in Chronocrash the current OGG implementation would be replaced with a better one.

BTW, just a question, what did you use to debug if there's a mem leak?
 
This is not what I see here, I know about the debug function at options, I even use it most of the time, but the problem is how did he know about the pointers that lead to the memory leak? He's probably using an external debugger.
 
I detected memory usage with Task Manager(Windows Version).
I tested the latest Android version also and the problem was same.
 
Yeah, I see that. Since the Android port technically is using the same code, that will also happen as well. I checked the port and it seems that less memory is left on the phone's memory. Yes, the frame rate is still at best, but the battery life is of concern here since the CPU will have double the effort to clean memory.
 
Back
Top Bottom