Skip to content

Finding out memory usage in C++ #8082

@pweiskircher

Description

@pweiskircher

We have a pretty big app running using Emscripten that has to handle some pretty big PDF files sometimes. We try to cache as much data as possible, to make runtime performance as good as possible. On iOS and Android, we use the OS memory notifications to reduce memory as needed.

I haven't found a way yet in WASM/asmjs to do something similar. I understand there aren't any memory notifications, but, for example, is there a way to get the size of the heap when ALLOW_MEMORY_GROWTH is defined?

Basically, any information that I can query at runtime to see how much memory is used or available would be extremely beneficial. Our application is unfortunately not designed to behave correctly when malloc fails (due to so many operating systems simply overcommiting anyway), so we're running into OOM situations quite often.

BTW, thanks for all the work on it, it's been working really great so far!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions