Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a GOMEMLIMIT analog in TinyGo? #4280

Open
vlkv opened this issue May 31, 2024 · 2 comments
Open

Is there a GOMEMLIMIT analog in TinyGo? #4280

vlkv opened this issue May 31, 2024 · 2 comments

Comments

@vlkv
Copy link

vlkv commented May 31, 2024

Hi!

In my case I have an app which produces a lot of garbage and it crashes with OOM because of that (not a memleak). TinyGo's GC could be more aggressive at times when occupied space is close to some soft limit, set by GOMEMLIMIT (This env is from the Google's Go https://pkg.go.dev/runtime#hdr-Environment_Variables).

@dgryski
Copy link
Member

dgryski commented May 31, 2024

The TInyGo garbage collector first searches for enough space to satisfy the allocation; if that fails, then it runs a garbage collection and tries again; if that fails to find enough space, then the heap size is increased until the allocation can be satisfies or the underlying system runs out of memory. If you're encoutering OOMs then my guess is you're experiencing memory fragmentation which is impeding the garbage collector. There is enough space free, just not in a contiguous block.

@vlkv
Copy link
Author

vlkv commented Jun 3, 2024

@dgryski Thank you for your comment. I am experiencing that after refactoring, my app gets OOMs in some test cases. I have studied the code before and after and cannot find a cause (the code before the refactoring creates a lot of small objects too, so if it is a memory fragmentation, then why the things got worse, I cannot explain)... I am using the -gc=precise and target is wasi BTW.

Are there some debugging tools available for TinyGo that could help to diagnose the roots of the OOMs? For example:

  • pprof for TinyGo?
  • some debugging log from GC?
  • anything else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants