sharpie7 / circuitjs1

Electronic Circuit Simulator in the Browser
GNU General Public License v2.0
2.29k stars 633 forks source link

Firefox memory hogging #592

Closed dzarda closed 3 years ago

dzarda commented 3 years ago

It appears we're allocating a lot of objects during the run. Even with the RLC circuit the memory consumption tops at 2.3/8G as seen here:

obrazek

The problem manifests itself as repeating periods of normal operation followed by drastic reduction in performance characterizable as periodic denial of service. I was not able to pinpoint what the allocations pertain to.

obrazek

FF profile here profile.zip

FF memory snapshot here 45260033.zip

Not encoutered in Chrome (different GC policy?)

obrazek

pfalstad commented 3 years ago

Someone reported this already as #490, but that got closed.

I think it is this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1586495

The more resistors in the circuit, the more memory is leaked. See Circuits->Other Passive Circuits->Resistor Grid 2 for a particularly bad example. Only happens on Windows, not Mac.

As a workaround, uncheck "Options->Show Voltage". I'm not sure if we can work around this in the code. The CanvasGradient objects don't seem to be very reusable, and there's no way to explicitly free them.

dzarda commented 3 years ago

Okey thanks, I was wondering if this is a FF defect after I saw low memory usage in the mem snapshot.

dzarda commented 3 years ago

Commented there https://bugzilla.mozilla.org/show_bug.cgi?id=1586495

dzarda commented 3 years ago

Wow they fixed the problem in latest Beta! Closing