In memory growth the heap will grow, but we never shrink it. This could be added I think, but the reason it hasn't been a priority is that often memory fragmentation makes it impossible anyhow - that is, if you allocate 1000 things and free everything but the one allocated to the highest address, then we can't shrink, since we can't create holes.
You may want to look at the SPLIT_MEMORY option which does support holes and shrinking, but it is much slower. On Mon, Aug 28, 2017 at 9:16 AM, <[email protected]> wrote: > Hi, > I am porting comlex logic inside C++ to WASM. > When I run it in browser. It looks like there is no memory release at all > till I reload page. > I even tried it on simple program. > I usually allocate memory with new operator and release it with delete > inside C++ code. But browser does not release memory. > I tested it on Chrome and Firefox. > I used -s ALLOW_MEMORY_GROWTH. But the logic is complex and sometimes it > takes 2 GB RAM to fulfill operations and then browser stops executing > script. > I know that emscripten allocate big part of memory for all operations. But > when I use this algorithm on my PC from console it takes 100 - 200 MB RAM. > > Is there any chance to make emscripten release memory imidiately from C++ > code. Or this is a bug ? > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
