SOMStack can cause memory leaks
ltratt opened this issue · 3 comments
At the moment, SOMStack
does not overwrite Val
s when they are popped/truncated (instead it simply adjusts the list's length), so rboehm probably ends up keeping alive otherwise-dead objects in some cases. We could overwrite values with Val::illegal
but the nicest way of doing things would be to define a custom trace function for SOMStack
. CC/@jacob-hughes
[I also wonder if Vec
s have the same issue?]
I also wonder if Vecs have the same issue?
They do e.g. Vec::truncate
drops items but does not overwrite the memory https://github.com/rust-lang/rust/blob/master/library/alloc/src/vec.rs#L748
Are there many place you use Vec
? SOM doesn't have a dynamically sized data structure, I think. Except perhaps in the implementation. A quick search shows you're using it for Array
yksom/src/lib/vm/objects/array.rs
Line 33 in 4d8020f
Though, arrays can't be resized in SOM, so, that shouldn't be really an issue.
The comment about Vec
isn't really very yksom related: it's more something we need to think of with rboehm and friends in general. So I'm arguably guilty of raising that aspect of the problem in the wrong repo!
I have a local branch which gets rid of the Vec
in Array
, but we first have to convince ourselves that #172 is a good idea.