Re: [eigen] tracking memory usage? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] tracking memory usage?
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Tue, 14 Sep 2010 02:07:40 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=RxGFwp73wTShHC715z1EZEcFfqe0q18HNoNqHbkPMOk=; b=ABVLzH1r5kRYe43QDb3UgzOUC/ZRDdcmU/+6Paxkvo3wwNwQd5PHvo6jzjZhtTlRk4 8I3jkmjA8b9dvuiViQRr5ssvW7sPTuFp9w+e518Glk/O2tUXR7ZmEnJDZJZasmd/9jf8 viNqQDu/yj36enhiicDK70ZzJx8oNnoMAwSOU=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=RGiqWRrJ/Fu1xEBIQWlv+OtFRWQO9k0fz4dzRRK/YCKD4JCbHcMdgcXbuI5jPXkyxA LVVqV5XhN5ewVVUhzjRBpRVbMm9QDdwnx+Ma4VE4GTi1uBfCE0Fg8eQu7RkG3eRFrg80 mcSfhLJeOewjDo8DgBVEgRuLa0dz6iw/czqxE=
2010/9/13 David Roundy <roundyd@xxxxxxxxxxxxxxxxxxxxxxx>:
> Hi all,
>
> I've written a program using eigen2, without paying too much attention
> either to time or space efficiency. I'm now confident that the
> program is correct (so far... but it's not complete), and am looking
> to refactor it to reduce memory consumption.
>
> Ordinarily in C++ I would figure out where the memory is going by
> instrumenting the constructors and destructors of large data types to
> track net memory use and log it (and log who allocated it). I can do
> the same thing with some of my code in this case (since I derive a
> subclass of VectorXd), but that won't count any actual VectorXds that
> get allocated directly.
You can do several things:
- first of all, all heap allocations done by eigen go through the few
functions defined in Eigen/src/Core/util/Memory.h. So you would only
have to instrument them, if all you want to do is instrument the heap.
Alternatively, if you run linux, you can use valgrind's various tools.
- if you want to count Vector/Matrix/Array objects, you only have a
few classes to instrument, since they are all specializations of the
same few classes. Vectors and matrices all are the Matrix<...> class
template, for instance.
> My primary approach I expect to be switching functions that currently
> accept (const VectorXd &) to accept instead somthing like (const
> Eigen::MatrixBase <OtherDerived>&) to enable lazy evaluation of
> expressions. My understanding is that creating functions that
> *return* a lazily evaluated vector is tricky...
In order to achieve that you have to let it return an expression
object. You need to figure the right return type, probably by reading
Eigen source code: DenseBase.h MatrixBase.h and the files under
src/plugins/ defining the common operators.
Benoit
> Any suggestions or hints, of approaches that work effectively in
> improving memory use in eigen2 programs? (Or if it'd be worth
> switching to eigen3?)
>
> Thanks for the great package!
> --
> David Roundy
>
>
>