Closed kerneljake closed 6 months ago
Part 2: You can still induce a memory leak (albeit at a slower rate) by cycling album artwork. Queue up a Random Mix and then cycle through the album art of each song by clicking the Next button, and you'll see the memory increase when the artwork is updated. There are two other places in SDL_QuartzVideo.m where the rectangles are redrawn, and when I patch them all, I can't see any more leaks.
Ouch... it looks like this messes up the window when you hide/unhide. It stays messed up until you click on a widget or try to resize the window. Is this the "white on white" problem described in d3b88cffb ? More investigation needed.
This is awesome! I've been aware of the memory leaks in the mac version, it's been that way for a very long time, but I was never able to isolate the root cause.
Two problems surfaced when moving the Quartz window refresh to the main thread.
I was hoping this patch would remain 100% in the macOS specific code, but I touched initSDL() in jive_framework.c. Calling SDL_PumpEvents() should be harmless, but it means that other OSes will need to be tested.
I see the memory usage increase when new cover art is loaded in Now Playing; however, now it seems to cap out with an upper bound instead of increasing forever.
There are two unrelated fixes contained here for things I found along the way:
Test cases:
Tested on:
After some research, I've discovered that rather than putting the call to SDL_PumpEvents in process_events, the jive framework provides a facility to call it on a per platform basis. I've attached a patch against the current PR#19 to implement it. I've found it works as expected on both intel and m1 macs. Can you try it out and confirm? I'd like to get these changes into the source tree soon. 19a.patch.txt Thanks.
I confirm it works on both chipsets. What advantage does calling it on a per-platform basis yield -- i.e. does Linux now need its own handler, too?
None of the other platforms require the call. So isolating it to macos just removes the chance of the change breaking one of the other supported OS types. Thanks for confirming the change works for you too.
Was 19a.patch.txt supposed to be merged as well?
Thanks for catching this. I missed the changes to platform_osx.c from 19a.patch.
This patch fixes a memory leak in macOS Squeezeplay induced by redrawing the rectangles of scrolling text in the Now Playing applet. To reproduce the symptom, set the screensaver to Now Playing with album and track names whose lengths exceed the width of the screen and require scrolling. Let Squeezeplay run for awhile, and you will see the memory usage creep up in Activity Monitor every time the text scrolls. Left running for too long, the app will eventually consume gigabytes of virtual memory.
This doesn’t happen with the Linux build, which helped me narrow it down to Quartz. The root cause is outlined in this stackoverflow article. The leak is avoided by forcing redraws to happen in the main thread.
You can examine the memory usage with the following steps.
This will output a trace like the following.
Tested on 10.13.6 x86_64 and 13.6 arm64