This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen

Bug 1185

Summary: SparseMatrix class does not enforce the EIGEN_NO_MALLOC macro
Product: Eigen Reporter: velin <n.clauvelin+bugzilla>
Component: SparseAssignee: Nobody <eigen.nobody>
Status: DECISIONNEEDED ---    
Severity: Internal Design CC: chtz, gael.guennebaud, n.clauvelin+bugzilla
Priority: Normal    
Version: 3.2   
Hardware: All   
OS: All   
Whiteboard:

Description velin 2016-03-29 19:23:06 UTC
(this might have been reported already or it might be a "feature" but just in case I prefer to open a ticket)

The SparseMatrix class (defined in SparseCore/SparseMatrix.h) does not enforce the EIGEN_NO_MALLOC macro; "std::malloc" and "std::free" are directly called at various locations in the code (as far as I can tell it seems to always be related to resizing operations on the inner and outer indices storage).

I am not sure this is to be considered as a bug but it is somewhat troublesome that in spite of defining the EIGEN_NO_MALLOC macro there are still malloc calls behind the scene.

It seems the fix would be easy to implement by using the functions defined in Memory.h; I can provide a quick draft if needed.
Comment 1 Gael Guennebaud 2016-04-05 11:28:02 UTC
In the sparse world, almost any operations will perform dynamic allocation, so I don't see much use case to extend this debugging mechanism to sparse matrices. Recall that EIGEN_NO_MALLOC does not change the behavior of Eigen: it only helps in debugging code.
Comment 2 Christoph Hertzberg 2016-04-05 11:52:03 UTC
I don't see anything wrong with having EIGEN_NO_MALLOC also affect sparse operations.
There are several operations which do not alloc, e.g., matrix*vector products or inserting values into a properly pre-allocated matrix.
Maybe a small nitpicking thing against it is that sparse matrices use new/delete instead of (aligned_)malloc/(aligned_)free (so the naming of the macro does not fit).
Comment 3 Nobody 2019-12-04 15:34:42 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1185.