HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.15k stars 658 forks source link

Exception-related memory leaks on neko #10646

Open Simn opened 2 years ago

Simn commented 2 years ago

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.

RblSb commented 2 years ago

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

Simn commented 2 years ago

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 commented 8 months ago

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

kLabz commented 8 months ago

I've seen this leak on macro context btw

Simn commented 8 months ago

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.