-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory issue with subassignment #36
Comments
Take a look at FWIW, I wouldn't call this a memory leak, rather I'd say this subassignment is something you want to avoid doing without realizing the result fairly soon afterward. |
As Pete said, this is not memory leak, just growing an object. The more delayed operations a DelayedArray object is going to carry, the bigger the object is going to be in memory. Delayed ops are represented by DelayedOp objects. There are currently 8 types of DelayedOp (see Furthermore, when various subsetting operations are applied to a DelayedArray object (consecutively like in To summarize, all delayed operations have 2 costs: (1) the cost of representing them (i.e. the memory footprint of the DelayedOp objects that represent them), and (2) the cost of realizing them. (1) is paid immediately and (2) is paid later at realization time. (1) is generally small but can become significant if the DelayedArray object carries many delayed operations that cannot be simplified. For example, doing So the advice is: even though a DelayedArray object supports delayed operations, one needs to be careful to not accumulate too many operations on it. Especially if the operations are subassignments, which can be expensive to represent (if the "left index" is big) and cannot be simplified. Hope this makes sense. |
Unfortunately this is the real use case where the matrix needs to be partially updated multiple time within the loop. After the entire process is finished, the memory usage of the |
Does Bigmemory support in-place replacement of values? This might be better than delaying the subassignment, for this use case. |
It would indeed. Because each realization will copy the entire data set! Anyway FWIW I've started to put together some notes for how to implement a realization backend here: #37 For your use case, if Bigmemory supports in-place replacement of values and you feel like taking the BigmemRealizationSink route, then you might consider implementing an
Note that there is no |
@mikejiang Can we close this one too? |
The new feature introduced by #32 seems to have memory leak issue, as the example shown below the
DelayedArray
object gets bigger after each iteration of subassignmentCreated on 2018-10-01 by the reprex package (v0.2.1)
The text was updated successfully, but these errors were encountered: