[ODE] SIGSEGV in dSolveLCP() at ode/src/lcp.cpp:1137

Jon Watte hplus-ode at mindcontrol.org
Fri Feb 13 10:11:56 MST 2004


Branches are evil. Think of each branch as costing you 40 arithmetic ops.

Cheers,

			/ h+

-----Original Message-----
From: ode-bounces at q12.org [mailto:ode-bounces at q12.org]On Behalf Of
Michael Lacher
Sent: Friday, February 13, 2004 1:34 AM
To: ode at q12.org
Subject: Re: [ODE] SIGSEGV in dSolveLCP() at ode/src/lcp.cpp:1137


Nguyen Binh wrote:
> Hi ,
> 
>    The problem is vanilla malloc() /free() is incredibly slow compare
>    to alloca()(somewhat about 1000 times).
> 
>    So if you try to implement a new mem alloc in ODE, I suggest not to
>    use vanilla malloc(), free() but to :
>        1) Allocate a big chunk() of memory initially
>        2) Implement new malloc() and free() based on that chunks.
> 
>        These can be done easily cos there are many such things around.

I personally would prefer if there are interfaces for memory allocation 
like there are in FMOD. There would have two possibilities:

a) give it a memory pool that you allocated somewhere and it uses its 
own allocators in this pool and never asks for more or uses more.

b) give it function pointers to malloc/realloc/free functions and it 
uses those, not using a pool (you are responsible for pools, ...)

I would enhance this a bit for ODE to make it transparent and usable 
without memory limits:

1. Specify three seperate memory allocation methods:
    a) stack allocation using alloca with a userdefined allocation limit
    b) allocation in a preallocated pool (using own stack or similar 
fast method) with a limit given by the pool size
    c) dynamic allocation using user given malloc pointers

2. Specify some rules as to when and how to use each one of those methods:

   IF amount < allocaLimit THEN use alloca
   ELSE
     IF pool available and amount fits in pool THEN use pool
     ELSE
       IF custom malloc is set THEN use custom malloc
       ELSE use malloc

Using these rules thebehavior can be finetuned easily:
* default ODE behaviour: allocaLimit=infinity
* only malloc: allocaLimit=0, pool=0, custom malloc=0
* only custom functions: allocaLimit=0, pool=0, custom malloc = user 
defined function
* preallocated memory pool with fixed size (example: console): 
allocaLimit=0, pool=user given pool, custom malloc=out of memory error 
routine (could enlarge pool dynamically)


3. Add some interfaces to set the parameters:

unsigned int dSetAllocaLimit(unsigned int limit);

param: the new limit you want to set (0 to disable use of alloca)
returns: the limit used (might be checked agains stack size, or 
availability of alloca)

unsigned int dSetMemoryPool(void* pool, unsigned int poolSize);

param1: pointer to start of pool
param2: size of pool in bytes
returns: actual size used (after alignment is done, ...)

void dSetCustomAllocationFunctions(void* (*mallocFunc)(unsigned int 
size), void (*freeFunc)(void* data));
param1: custom malloc function
param2: custom free function
return: nothing

Some apropriate get methods would be useful too :)

mucki
-- 
Honeder Lacher Wallner Softwareentwicklung OEG
Founder / Developer

http://www.hlw.co.at
michael.lacher at hlw.co.at
+43/ 1/ 9134716

_______________________________________________
ODE mailing list
ODE at q12.org
http://q12.org/mailman/listinfo/ode




More information about the ODE mailing list