You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm playing with both the bindings for Julia and Python, and while working with residues on a liposome, I found that, in the Julia version, Residue and residue_for_atom are making copies of the residue instead of giving a view, like in the Python version where a raed-only access is given. The problem is that the Julia version is unusable for me because of the memory consumption that comes with doing so much copies of potentially big data structures.
Is there a workaround that I haven't been able to find? Otherwise, I think that we should be using views or giving the possibility to choose if the function does a copy or not
The text was updated successfully, but these errors were encountered:
There is indeed a difference between Python and Julia here. The core of the issue is that they use different garbage collection strategy, and Python ends up cleaning up much earlier, while Julia keeps stuff around until there is more memory pressure.
This made it so that handing out views in Julia could cause segfaults, if the view was pointing in memory that was re-allocated in the mean time:
atom =@view frame[3]
add_atom!(frame, Atom(...))
add_atom!(frame, Atom(...))
add_atom!(frame, Atom(...))
add_atom!(frame, Atom(...))
name(atom) # can segfault depending on the memory allocator behaviour
This is the reason why I went with a copy in Julia by default.
The proper way of solving this would be to emit an error in add_atom! if there are still references to atoms floating around. This could be done in C++, but I did not had the time to implement it for now.
At the same time, I understand the need to use views instead of copies in a lot of cases, and doing so without modifying the frame should be perfectly safe. #53 started to add back opt-in support for views, and I would be happy with a view=true parameter to Residue and residue_for_atom.
Is this something you could help implement? You can use #53 as an inspiration on how to do it.
I would be glad to try to implement that.
I'm in a pretty busy period so I'm afraid I'll have to work on this in my spare time, but I'll definitely try.
Thanks for the deeper explanation of the problem and for pointing me to #53
I'm playing with both the bindings for Julia and Python, and while working with residues on a liposome, I found that, in the Julia version,
Residue
andresidue_for_atom
are making copies of the residue instead of giving a view, like in the Python version where a raed-only access is given. The problem is that the Julia version is unusable for me because of the memory consumption that comes with doing so much copies of potentially big data structures.Is there a workaround that I haven't been able to find? Otherwise, I think that we should be using views or giving the possibility to choose if the function does a copy or not
The text was updated successfully, but these errors were encountered: