[ODE] Segfaulting ODE with too many objects -- ALLOC vs MALLOC

Jon Watte (ODE) hplus-ode at mindcontrol.org
Sat Sep 30 10:10:13 MST 2006


alloca() is a LOT faster than malloc(), because it doesn't have to worry 
about locking and contention. This is especially true in threaded 
applications with heavy load.

There already exists a contribution/patch that changes alloca to use 
malloc/free instead. You can use this if necessary and desired.

Btw: using cygwin on Windows just isn't the best way to develop a 
Windows application, because it doesn't support all things necessary to 
integrate well with Windows. I highly recommend using Visual Studio instead.

Cheers,

          / h+


Kyle Hubert wrote:
> On 9/26/06, Kyle Hubert <khubert at gmail.com> wrote:
>   
>> Is there a definable upper bound to the number of objects ODE can
>> handle at one time? I seem to have the ability to run a simulation
>> fine with N number of Geoms, but at N+1 the simulation segfaults with
>> the error seen below.
>>     
>
> OK, so it appears that for dWorldQuickStep it calls SOR_LCP on line
> 340 in quickstep.cpp for release 0.7. This function uses alloca to
> find room for all the dReals and the IndexError structs. In my
> particular case, there isn't enough room on the stack, since I'm
> constrained to cygwin/Windows ulimit won't let me bump my stack.
> Anyways, this brings me to a curious question.
>
> Why is everything on the stack? Is this to avoid having to keep track
> of frees? I replaced the allocas with malloc/frees and everything
> worked. Now I can have a lot more objects. Is this beneficial to
> anyone else? I understand there would be a few more clock ticks of
> overhead for the malloc function as well as free, but using the stack
> is a little limiting.
>
> If I do change the behavior would anyone else appreciate this? I can
> use a preallocated pool or even a freelist/realloc. Any of the old
> tricks from the book, anything but just a stack allocation.
>
> With malloc/free we can even give concise errors that we are out of
> heap and return, rather than segfaulting.
>
> Yes? Anybody?
>
> -Kyle
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
>
>
>   


More information about the ODE mailing list