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

Memory leaks #1311

Open
ryandesign opened this issue Jan 19, 2024 · 3 comments
Open

Memory leaks #1311

ryandesign opened this issue Jan 19, 2024 · 3 comments

Comments

@ryandesign
Copy link
Contributor

ryandesign commented Jan 19, 2024

In the macOS Metal version at least, when an emulated machine is running, Clock Signal uses more memory the longer it is open. Please check for memory leaks. For example, in Xcode, select Profile from the Product menu and then choose the Leaks template.

I'm on macOS 14.2.1 today, on my 2012 15" MacBook Pro with Retina display, using the code from git as of yesterday (3ee81ef). I'm using an Apple IIe emulation. The problem happens regardless of whether I'm using the integrated or discrete GPU. The memory usage increases more slowly if the frame rate is lower (e.g. because of #1178).

@ryandesign
Copy link
Contributor Author

I'm not familiar with using the Xcode/Instruments Leaks tool. I think it is supposed to detect leaks, but for me it only seems to detect a couple small leaks early in the run of the program, not the ever-increasing memory use while an emulator is running. I think it may be because these are Objective-C objects rather than plain C allocations. It does show an increasing number of allocations of particular sizes, though, and you can drill down and see which lines of your code caused those allocations. Maybe a corresponding release is missing or an autorelease pool needs to be added.

@ryandesign
Copy link
Contributor Author

I should add that the memory leak is fairly significant in that it adds up pretty quickly. For example, after leaving an Apple IIe emulator running for maybe half an hour playing a few games of Tetris, Clock Signal is using over 20GB of memory. Closing the emulator window then takes quite a bit of time, with a spinning beachball cursor, while the OS frees all that memory.

The problem doesn't happen in the SDL/OpenGL build on the same Mac.

@TomHarte
Copy link
Owner

TomHarte commented Mar 3, 2024

Noting that I'm unable to reproduce; there is a leak in Apple's Metal analysis tooling which affects runs in Instruments but outside of that:

Screenshot 2024-03-02 at 21 29 57

i.e. after an hour and ten minutes of CPU time, which at around 19% CPU utilisation is a bit more than six hours of wall clock time, the application is still using only around 90mb of 'real' memory, which even per the dedicated memory tab is less than 300mb:

Screenshot 2024-03-02 at 21 30 23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants