Using malloc/free multiple times leaves less memory?

My application calls malloc in multiple subroutines, finally releasing all using free. This is done using my zalloc library (see my other post: ).

Somehow, when the applications tries to detect the available ammount of memory at the end of the test (allocating, freeing, testing), the freemem function gives me about 4-6MB less memory than at the start of the test? (out of 21MB available on the device at the start).

Anyone knows what can cause this?

All memory is allocated and freed using the malloc/free routines within the library, with the exception of the SDL functions, which are registered externally on allocation and release.
Last edited on
Other page 404s.

Hard to tell without seeing the code to see what has been allocated and what hasn't.

Why are you using malloc and free over new and delete?
The 404 is because the close paren and period got included in the URL:

Most likely the reason is that your code is faulty.
The memory is just allocated using malloc and freed (only with valid pointers or freezall) with free. When just malloc and free are used, can this be caused by other factors (function calls etc.? Afaik they use the stack to store their return parameters, or are the stacks allocated on the heap too? Threads are allocated with sceKernelCreateThread with a 0x10000 stack size ( ))

Edit: seems the library works just fine. The problem was with some allocation/deallocation calls in some other functions and heap corruption with unchecked allocated data (overflow in a malloc area).
Last edited on
Topic archived. No new replies allowed.