[ODE] segv with memory allocation using dALLOCA16

Shaul Kedem shaul_kedem at yahoo.com
Fri Nov 23 03:36:01 MST 2001


Hi,

--- Russ Smith <russ at q12.org> wrote:
> 
> > 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.

alloca on win32 is evil. How about #ifdef-ing  WIN32
and using malloc instead? the heap (which is not a
heap anymore) in msvcrt is rather good.

> 
> > 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.

the reason I keep bringing this up is that I tracked
down the thread creation in ODE, made it a *lot*
bigger (over 10MB in size) but still the whole thing
goes flying out the window (get it? window... heh)

shul

__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1



More information about the ODE mailing list