Does R ever move objecsts in memory?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Does R ever move objecsts in memory?

Ross Boylan
R objects can disappear if they are garbage collected; can they move,
i.e., change their location in memory?

I don't see any indication this might happen in "Writing R Extensions"
or "R Internals".  But I'd like to be sure.

Context: Rmpi serializes objects in raw vectors for transmission by
mpi.  Some send operations (isend) return before transmission is
complete and so need the bits to remain untouched until transmission
completes.  If a preserve a reference to the raw vector in R code that
will prevent it from being garbage collected, but if it gets moved
that would invalidate the transfer.

I was just using the blocking sends to avoid this problem, but the
result is significant delays.

Thanks.
Ross Boylan

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Does R ever move objecsts in memory?

Duncan Murdoch-2
On 14-03-16 7:51 PM, Ross Boylan wrote:

> R objects can disappear if they are garbage collected; can they move,
> i.e., change their location in memory?
>
> I don't see any indication this might happen in "Writing R Extensions"
> or "R Internals".  But I'd like to be sure.
>
> Context: Rmpi serializes objects in raw vectors for transmission by
> mpi.  Some send operations (isend) return before transmission is
> complete and so need the bits to remain untouched until transmission
> completes.  If a preserve a reference to the raw vector in R code that
> will prevent it from being garbage collected, but if it gets moved
> that would invalidate the transfer.
>
> I was just using the blocking sends to avoid this problem, but the
> result is significant delays.
>

If the object is unchanged, it won't move.  If you modify it (e.g.
assign a new value to one element of a vector), it may be duplicated and
the result after the change will be at a new location.

Duncan Murdoch

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel