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

ever-increasing memory usage -- specially on WASM #4851

Closed
flipbit03 opened this issue May 26, 2022 · 11 comments
Closed

ever-increasing memory usage -- specially on WASM #4851

flipbit03 opened this issue May 26, 2022 · 11 comments
Labels
C-Performance A change motivated by improving speed, memory usage or compile times O-Web Specific to web (WASM) builds

Comments

@flipbit03
Copy link

Bevy version

0.7.0

Operating system & version

Windows 10, Ubuntu 20.04, also WASM

What you did

Ran my game for a hour while checking world entity count and other stuff, which was stable.
Memory usage kept growing, regardless of entity count.
Native build memory grew 2mb in a hour, which was quite okay.
Running on a tab in Google Chrome, the Wasm build of the game keeps growing in memory usage.

What you expected to happen

That the memory usage would be constant if we are not growing in entity amount.

What actually happened

We noticed a sensible but every growing memory increase in Local builds, and growing by quite a bit in the WASM builds.

Additional information

@alice-i-cecile @james7132 and @devil-ira have been given access to my game's source code to debug/possibly check.

@flipbit03 flipbit03 added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels May 26, 2022
@flipbit03 flipbit03 changed the title ever-increasing memory usage -- Specially worrisome on WASM ever-increasing memory usage -- specially on WASM May 26, 2022
@alice-i-cecile
Copy link
Member

So then the reason why memory usage grows so much on wasm is just the performance stuff.

This was the conclusion from our Discord conversation on the matter.

@alice-i-cecile
Copy link
Member

@flipbit03 when you get the chance, can you expand on my summary?

@alice-i-cecile alice-i-cecile added C-Performance A change motivated by improving speed, memory usage or compile times O-Web Specific to web (WASM) builds and removed C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels May 27, 2022
@superdump
Copy link
Contributor

@alice-i-cecile @flipbit03 where is the discord conversation?

@alice-i-cecile
Copy link
Member

The #WASM memory leak thread, starting at this message.

@superdump
Copy link
Contributor

So the reason for the leak seems to be Chrome performance instrumentation code rather than bevy app code. Apparently calling performance.clearMeasures() and performance.clearMarks() clears (most of?) the memory used for tracking memory usage (ironic right?) and so this was not a bevy problem.

@Niedzwiedzw
Copy link

rustwasm/wee_alloc#106 is this related?

@Tarnadas
Copy link

Thx @Niedzwiedzw, removing wee_alloc worked for me.
I had the problem that Chrome's garbage collector went crazy after couple of minutes until it crashed and disabling Chrome performance tools didn't make a difference

@Niedzwiedzw
Copy link

wowowow, really? I haven't tested yet, gonna do that when I grt home

@alice-i-cecile alice-i-cecile added the P-High This is particularly urgent, and deserves immediate attention label Aug 30, 2022
@alice-i-cecile
Copy link
Member

alice-i-cecile commented Aug 30, 2022

@Tarnadas, just to clarify, were you using wee_alloc in your own program and removing it fixed it? We don't appear to use wee_alloc in Bevy itself.

@alice-i-cecile alice-i-cecile removed the P-High This is particularly urgent, and deserves immediate attention label Aug 30, 2022
@Tarnadas
Copy link

Yes I was using it in my own program, because almost every WASM guide suggests to use it, if you want to shrink binary size.
I know that it’s not part of bevy

@bjorn3
Copy link
Contributor

bjorn3 commented Aug 30, 2022

The savings fron using wee_alloc instead of the default dlmalloc are neglectible in comparison with the size of bevy itself. In addition wee_alloc is slow and suffers a lot from memory fragmentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Performance A change motivated by improving speed, memory usage or compile times O-Web Specific to web (WASM) builds
Projects
None yet
Development

No branches or pull requests

6 participants