mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
memory leak investigation
This commit is contained in:
parent
82ff8a8edf
commit
0fdba3be56
2 changed files with 24 additions and 5 deletions
|
@ -2245,10 +2245,29 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
|
|||
let (value, layout) = load_symbol_and_layout(scope, symbol);
|
||||
|
||||
if layout.is_refcounted() {
|
||||
if value.is_pointer_value() {
|
||||
let value_ptr = value.into_pointer_value();
|
||||
let refcount_ptr = PointerToRefcount::from_ptr_to_data(env, value_ptr);
|
||||
refcount_ptr.decrement(env, layout);
|
||||
match value {
|
||||
BasicValueEnum::PointerValue(value_ptr) => {
|
||||
let refcount_ptr =
|
||||
PointerToRefcount::from_ptr_to_data(env, value_ptr);
|
||||
refcount_ptr.decrement(env, layout);
|
||||
}
|
||||
BasicValueEnum::StructValue(_value_struct) => {
|
||||
match layout {
|
||||
Layout::Builtin(Builtin::Str)
|
||||
| Layout::Builtin(Builtin::List(_, _))
|
||||
| Layout::Builtin(Builtin::Dict(_, _))
|
||||
| Layout::Builtin(Builtin::Set(_)) => {
|
||||
// let refcount_ptr = PointerToRefcount::from_list_wrapper(env, value_struct);
|
||||
// refcount_ptr.decrement(env, layout);
|
||||
eprintln!("we are likely leaking some memory, see #985 for details");
|
||||
}
|
||||
_ => unreachable!(
|
||||
"decref on weird type, likely a closure? {:?}",
|
||||
layout
|
||||
),
|
||||
}
|
||||
}
|
||||
_ => unreachable!("cannot be decref'd"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue