[ODE] Allocation problem?
jonathan klein
jk at spiderland.org
Wed Jun 7 18:28:16 MST 2006
On Jun 7, 2006, at 8:53 PM, Geoff Carlton wrote:
> It would be interesting to revisit this after 0.6, and fix it once
> and for all.
>
> I had a look through the previous postings . The posted patch,
> which mallocs if "full" would appear to leak memory, unless of
> course FREEA was added for every ALLOCA call. In general that sort
> of solution looks the right way to go though.
No "free" call is needed for the posted patch and no memory should be
leaked. The patch creates a StackMemory object on the stack for each
ALLOCA call. The StackMemory destructor, called when the function
exists, reclaims the memory.
The "malloc" that happens when the StackMemory stack is full will
cause the StackMemory stack to increase as necessary over the course
of the program's execution. It's true that the code (as posted)
never frees this memory, but the memory will never increase beyond
the max size required to solve the most complex world step.
- jon klein
More information about the ODE
mailing list