Memory leak in editor

Editing a specific script in my game causes the linter to infinitely consume all of my ram. I have traced the leak to Luau::Normalizer::unionSaturatedFunctions but I do not know what is causing it to infinitely allocate. I have been only been able to reproduce the issue in my game. I’ve tried moving the same script to another game and trying to reproduce the issue but have been unsuccessful.


image

A private message is associated with this bug report

8 Likes

Hi, thank you for filing this issue.

Can you please check if you have the “New Luau type solver” or “Incremental type checking…” betas on?

Thank you!

hello,

both beta features are enabled. disabling both of them seems to fix the leak.

It would be helpful to know if it happens with one on and not the other.

Also, as an aside, continuously growing memory usage and leaking memory are not the same thing. It’s better to air on the side of describing the symptoms, rather than prescribing the cause.

I have just tested it, the issue only appears when “New Luau type solver” is enabled.

The underlying cause is most likely that a type (likely an inferred type, rather than one you wrote down) is exhibiting exponential blowup in our type normalization algorithm. The fact that autocomplete itself stops working is a good indication of this (since autocomplete is awaiting the result of type inference to be able to provide its suggestions). If the location you’ve traced it to is actually correct, that would indeed touch on exactly one of the situations where exponential blowup is plausible: combining overloaded functions. We’ll investigate further, but it’d be more apt to describe the problem as type inference running “forever,” rather than a memory leak.

the location should be correct. I hooked malloc, free and realloc to track where the memory was being allocated.

here is a partial stack trace:

Luau::Normalizer::unionNormalWithTy
	-> Luau::Normalizer::intersectNormalWithTy
		-> Luau::Normalizer::intersectFunctionsWithFunction 
			-> Luau::Normalizer::unionSaturatedFunctions
1 Like

Thank you for the investigation, I’ll update the ticket accordingly.

As previously explained, this kind of denial of service for autocompletion and the associated continuously increasing memory usage is unfortunately the current outcome of severe performance edge cases from type inference, which the New Type Solver is more prone to as we’re working through these issues. You can avoid the problem today by opting out of using the New Type Solver while we continue to work on these issues. In the interest of making our tickets manageable, I’m closing this as a duplicate of New Luau Type Solver - Type Solver Doesn't Activate.