octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: malloc/erase


From: Dmitri A. Sergatskov
Subject: Re: malloc/erase
Date: Mon, 29 Mar 2004 12:47:07 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040115

Since we are on the subject of malloc, are you aware of:


http://math-atlas.sourceforge.net/errata.html#malloc

<<<<
However, by default Linux (as well as some other OSes, such as OS X) allocates 
non-trivial
sized allocations using mmap, which means that when free is called, the memory 
is
immediately returned to the system. Thus all malloc calls have extremely high 
overheads.

This is not a big problem if you are doing a large matrix multiply, where the 
cubic
computation disguises this square cost. For small problems, though, the O(N**2) 
costs
are actually dominant, and this type of malloc behavior effectively doubles them
(at least). You should be able to change Linux's malloc behavior by setting 
these
environment variables:

   setenv MALLOC_TRIM_THRESHOLD_ -1
   setenv MALLOC_MMAP_MAX_ 0
...
>>>>

That tells me that one can expect OS dependence of the malloc timing.

Sincerely,

Dmitri.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]