Prevent future memory leaks #2857
Replies: 4 comments
-
Detect Memory LeakI think we should throw more tools at it, for example
|
Beta Was this translation helpful? Give feedback.
-
Miri is great, but insanely slow. I ran the conformance suite under Miri when I was worried if there was UB in my PR which introduced Personally I do think the best tool for this particular job is the compiler. This is exactly what trait bounds are designed for. |
Beta Was this translation helpful? Give feedback.
-
Not sure if this is an elephant in the room. How much cost for having |
Beta Was this translation helpful? Give feedback.
-
I have not measured it, but I would imagine very significant. Lack of
Yes it would. But an |
Beta Was this translation helpful? Give feedback.
-
We could prevent the possibility of any future memory leaks by:
Arena
.u32
,&str
etc.oxc_allocator
'sBox
,Vec
andString
.Arena
(same as a type can only beClone
if all its constituent parts are alsoClone
).#[derive(Arena)]
on all AST types.Allocator::alloc<T: Arena>
.The compiler will then make it impossible to add any type which owns data external to the arena to the AST, or allocate one in the arena.
Beta Was this translation helpful? Give feedback.
All reactions