[petsc-users] memory management of external libraries

Jed Brown jed at 59A2.org
Tue Sep 28 08:56:37 CDT 2010


On Tue, Sep 28, 2010 at 15:48, SUN Chun <Chun.SUN at 3ds.com> wrote:
> Sorry if this might be related to ML rather than PETSc. I have used
> PetscSetMalloc to override memory management of PETSc with my own code.
> Everything looks fine with PETSc. However I'm noticing that when using
> external library such as ML, we can't pass down our own allocator down. I
> believe this is a limitation from the interface of ML, though I'm not 100%
> sure.

ML just calls an unwrapped malloc.  You can link in a custom allocator
(with LD_PRELOAD or otherwise, see docs for any third-party malloc
such as tcmalloc), in which case everything that calls malloc will use
it (including C++ new on most systems).

Jed


More information about the petsc-users mailing list