-
Notifications
You must be signed in to change notification settings - Fork 6
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
Memory check #399
Comments
From slack: Sam Reid [12:27 PM] Kathryn Woessner [12:38 PM] Sam Reid [12:54 PM] |
@ariel-phet reported this seems on the high side, would be worth an hour of investigation to (a) understand it better and (b) see if anything can be easily reduced. Also confirm there are no leaks. |
To help understand where the memory is used, I took a snapshot of memory for each screen: 1: 45MB It seems we should focus our efforts on screens 1-2 |
Also, I noticed every single subpath segment Line extends Events, not sure how much that increases the weight. I tried commenting all out |
Converting Segment to use TinyEmitter instead of extend Events saves around 1MB ~ 1% memory. I'll open a kite issue for that part. |
@ariel-phet after an hour or so, I found a place where excess memory was being used in kite and proposed an improvement. It should be analyzed and reviewed by @jonathanolson before we use it in production. Can you please visit phetsims/kite#79 and recommend a priority/timeline? Also, do you want more time spent on this issue, or is it at a good stopping point? UPDATE: one more note, the proposed change in Kite would improve other sims as well (proportional to how many shapes/subpaths they use). |
@samreid I find it suspect that the first 2 screens are both 45 MB, and the 3rd screen is nearly 10 MB less. These all have very similar functionality. Is something like the speaker causing this big discrepancy since the speaker has many many images associated with the moving cone? If so, The cone kind of looks like it can be drawn in code with some simple shapes and gradients. So I would at least like you to spend time to identify where that extra 10 MB is coming from. If the first two screens had the same memory footprint (or similar) to the 3rd screen I would be fine closing this issue. |
Side note @samreid if you do identify the speaker being the issue, drawing the cone in code might make a nice side project for an intern since I know your time is constrained. |
@samreid it was also noted in Design meeting that the "particle view" exists on the first two screens and not on the 3rd screen. Is there something about creating the particle view that adds all this memory? |
Here are some notes from memory analysis:
So it appears the SoundWaveGenerator takes up 3.6MB, but this is less than either the LightWaveGenerator or WaterWaveGenerator take. And deleting 20 of the 21 images in SoundWaveGeneratorNode does not impact the heap size. But a significant portion of the memory taken by any of the wave generators is the RoundStickyToggleButton. Combined, the 3 RoundStickyToggleButtons (one for each scene) takes a total of 9.4MB. However, I realized that PlaneWaveGeneratorNode creates one RoundStickyToggleButton for each scene, so this does not account for the difference between the scenes. I feel like I should investigate further but wanted to write down my progress. |
Comparing screen 1 to screen 3, I see this difference in heap allocations: There is a 5MB difference in allocation of Vector2, Bounds2 and Line, but it is not clear where these are coming from. I also tried switching to flat appearance in all round buttons, but that only saved around 1MB total (I believe this test was done for one screen) Use Flat appearance instead of 3d appearance in all round push buttons. |
I discovered that the Waves screens was creating secondary unused wave generators. In the preceding commit (before preceding comment) I removed these and saved about 5MB total. After this change, the total built sim is down to 84.5MB. @ariel-phet is this a good stopping point for 2.0? UPDATE: Also we are hoping to save another 1MB or so in phetsims/kite#79. |
@samreid thanks for investigating further, that seems to be down to a much better level. Closing. |
During #395 I noticed memory usage of this sim is on the high side. Can it be reduced?
99.3MB requirejs
90.9 built
The text was updated successfully, but these errors were encountered: