[ODE] segv with memory allocation using dALLOCA16

Russ Smith russ at q12.org
Thu Nov 22 12:42:07 MST 2001


> How come the stack is being used so much?

the ODE step routines create and destroy many dynamically sized arrays,
the largest being an m*m matrix. it is possible to do many malloc()s
and free()s every step, but this is slow, requires extra care to avoid
memory leaks, and can cause heap fragmentation. alloca() is almost free
and you don't have to worry about tidying stuff up. another important
benefit is that, because of the delayed cache writeback, it is faster
to reuse the same area of (stack) memory each time around, rather than
using a malloc() implementation that (may) cycle through all available
heap addresses.

> In the Windows version creating a thread with very
> large stack size is not recommendable.

for a (very) large system a 10Mb stack would be fine. surely that's not
too much to ask in a 2Gb (or whatever) windows process address space?
and the stack pages only get allocated if you actually use them.

russ.

--
Russell Smith
http://www.q12.org



More information about the ODE mailing list