haxe icon indicating copy to clipboard operation
haxe copied to clipboard

Exception-related memory leaks on neko

Open Simn opened this issue 3 years ago • 5 comments

I noticed today that a hello world program reports these memory leaks on neko:

Code_6CKwSgevPm

This is probably not a major issue, but I'm still pretty curious what's going on there.

Simn avatar Mar 28 '22 14:03 Simn

Can be related to https://github.com/HaxeFoundation/haxe/issues/10511

RblSb avatar Mar 28 '22 14:03 RblSb

The problem here is that the exception handling does load_instance after typing. This ends up in load_module, which does execute add_dependency ctx.m.curmod m2. However, during filtering, ctx.m isn't set correctly, so the dependency isn't added to the actual module. I have confirmed that this issue is fixed by changing ctx.m in run_expression_filters.

We're really not doing us any favors by having a typer context in the post-compilation stage. But this isn't going to be easy to change because some transformations such as inlining depend on it. I'll commit the curmod change for now, but in the long run I'd like to try and introduce some kind of filtering context that has a common context, but not a typer one.

Simn avatar Apr 14 '22 06:04 Simn

See https://github.com/HaxeFoundation/haxe/pull/11482#issuecomment-1926711876

Simn avatar Feb 05 '24 10:02 Simn

I've seen this leak on macro context btw

kLabz avatar Feb 05 '24 12:02 kLabz

If you get a hold of a scenario where this reproduces, please try adding tctx.m <- TypeloadModule.make_curmod tctx.com tctx.g c.cl_module; in filters.ml destruction next to the tctx.c.curclass <- c there.

Simn avatar Feb 05 '24 12:02 Simn