![]() Registered Member ![]()
|
When I copy an array B to an array A via A=B, does Eigen operate a copy, or will they share the data as long as only const members are accessed?
More generally where can I find information about the memory sharing policy in the documentation? |
![]() Registered Member ![]()
|
Hi poulejapon,
The data is copied right away, i.e. we are not using any COW (copy-on-write) policy. That is pretty much all there is to say regarding any sharing policy because sharing does simply not exist. Somewhat related to sharing is the memory mapping with Eigen::Map, see also here: http://eigen.tuxfamily.org/dox-devel/Qu ... ickRef_Map In general, in case one wants to share large objects in different modules in a library, I would go for shared_ptr. This applies of course only to heap allocated matrices because for stack objects sharing in this way does not make any sense because one would basically move the matrix to the heap by wrapping it in a shared_ptr. There, your only chance are references. Regards, - Hauke |
![]() Registered Member ![]()
|
thank you very much. That helped a lot.
|
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]