This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Zero sized mallocs

Tags: None
(comma "," separated)
nilshasler
Registered Member
Posts
1
Karma
0

Zero sized mallocs

Wed Feb 03, 2016 3:10 pm
Hi guys,

I am trying to eliminate memory allocation hotspots in my software. By overloading malloc and friends I am able to collect some statistics on which backtrace is responsible for most memory allocations. When looking at the sheer number of calls Eigen comes out on top with several locations allocating 0 bytes - millions and millions of times. Depending on the malloc implementation this may not matter but it may also cause some overhead.

In particular there are two functions that make up most of the zero sized allocations:

Eigen::Matrix<float, -1, 1, 0, -1, 1>::Matrix(Eigen::Matrix<float, -1, 1, 0, -1, 1> const&)
Eigen::Matrix<float, -1, 1, 0, -1, 1>::Matrix<Eigen::Block<Eigen::Matrix<float, -1, 1, 0, -1, 1> const, -1, -1, false> >(Eigen::MatrixBase<Eigen::Block<Eigen::Matrix<float, -1, 1, 0, -1, 1> const, -1, -1, false> > const&)

Shouldn't these be optimized away? Am I doing something wrong?
I tried compiling with EIGEN_NO_MALLOC but to no avail.

Any ideas?

thanks,
nils
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Zero sized mallocs

Sat Feb 06, 2016 8:25 pm
I cannot reproduce, even if I explicitly create and copy empty vectors. Could you paste a typical callstack triggering an empty malloc?


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft