Xcode15.4+, High CPU Usage and Increse Memory with SPM #1567
-
Describe the bugI found that RAM constantly increases when running on 1.9.1 version To ReproduceIn my project, uncomment the line, build the project and do nothing after launching the app, then, Memory will constantly increases in the built project If it remains uncommented, the issue never happens. It seems that something related to Memory Leak exists in the new version. lazy var stream: RTMPStream = {
HUBLog("stream init")
let stream = RTMPStream(connection: connection)
stream.frameRate = 30.0
stream.sessionPreset = .hd1280x720
stream.videoMixerSettings.mode = .offscreen
stream.screen.size = .init(width: 1280, height: 720)
stream.screen.backgroundColor = UIColor.white.cgColor
// stream.screen.startRunning()
stream.isMultiTrackAudioMixingEnabled = true
_ = stream.registerVideoEffect(backgroundVideoEffect)
return stream
}()
Expected behaviorNo Memory Leak Version1.9.1 Smartphone info.No response Additional contextNo response ScreenshotsNo response Relevant log outputNo response |
Beta Was this translation helpful? Give feedback.
Replies: 23 comments 2 replies
-
By the way, I get severe hangs when my Xcode-debugging app cold starts. For each App launch, they last for half a minute and UI freezes, then suddenly dismiss like they never exist. It is not a HaishinKit issue, but it appears recently, about after I take your suggestion to update my Xcode to 15.4. So I would like to ask you do you have any ideas about this? Is this an Xcode issue? |
Beta Was this translation helpful? Give feedback.
-
Same issue here with |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
After spending several days investigating a persistent memory leak, I finally traced the issue back to my own code. Interestingly, this leak only became apparent after updating to HaishinKit 1.9.1. So I still believe this version prone to cause To summarize, I wanted to share my findings with the community as it might help others facing similar issues. I will be closing this issue since the root cause has been identified within my own code. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@RainyTunes same case for me, This is not present in the demo project, I will continue to investigate. |
Beta Was this translation helpful? Give feedback.
-
I have similar Memory Graph diagram with yours, but I have no idea what these objects are. It was really strange, because when I made a few modifications several days ago , and then the memory leak disappeared. That caused me to make an incorrect temporary conclusion at that time. But now, the memory leak came again and I cannot solve it this time. |
Beta Was this translation helpful? Give feedback.
-
After checking I also have a small leak with 1.7.1 ! |
Beta Was this translation helpful? Give feedback.
-
I agree with what you said "more sensible to leak." However I have spend days optimizing incorrect retain circle and testing with deletion with unnecessary code, it seems very hard for me to find the source reason causing the leak. |
Beta Was this translation helpful? Give feedback.
-
v1.7.1 with Xcode 15.2 : OK v1.9.2 with Xcode 15.4: Leak (cannot test with 15.2, v1.9.2 can't compile with Swift version) |
Beta Was this translation helpful? Give feedback.
-
I believe reproducing it on my end is the fundamental solution. To confirm the reproduction method, please let me know the following information: It would be helpful to create a project that is close to the one where the issue is occurring. Please provide as much information as possible.
Additionally, it seems you are using effects, but does the issue persist if you turn them off?
|
Beta Was this translation helpful? Give feedback.
-
Does the same kind of leak occur in the Xcode 16 beta? Xcode 16 is coming soon, and everyone will be busy with iOS 18 support. Please make it possible to build with versions 15.3 and 15.2. I was also considering the option of giving up on 15.4 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I have Xcode 16 Beta on my another mac, and the memory leak can reproduce too on Xcode 16 Beta. |
Beta Was this translation helpful? Give feedback.
-
Hello. Does the same issue occur with this repository as well? |
Beta Was this translation helpful? Give feedback.
-
Hello @shogo4405, When I run your project with Xcode 15.4 I can see a memory leak : Another point If it can help with my project : I see the same CPU usage with your leak investigation project :) |
Beta Was this translation helpful? Give feedback.
-
Ah, thank you for the report. I was also concerned about the CPU usage. Additionally, The situation is different, but... I observed a significant increase in memory with iPadOS 18 + Xcode 16.0. On the other hand, with iPadOS 18 + Xcode 16.0, the demo version did not show any memory leaks at around 20% CPU usage. I think there must be some differences, so I would like to continue investigating. https://github.com/shogo4405/HaishinKit.swift/tree/main/Examples/iOSSwiftUI |
Beta Was this translation helpful? Give feedback.
-
Hi. Can I see your Xcode's Manage scheme options? Please turn off the Thread Performance Checker if it is currently on and check if it improves the situation.
|
Beta Was this translation helpful? Give feedback.
-
Hello, After some tests on my project, I observed the same result as you, turning off the Thread Performance Checker improves the situation (no more memory leak, and CPU usage is OK! |
Beta Was this translation helpful? Give feedback.
-
After following your guide, the issue has been resolved! Thank you for being so support again. I think it would be great if the guide could be put in the README, as other developers may encounter the same issue |
Beta Was this translation helpful? Give feedback.
-
By the way, could you please share how you identified that the Xcode Thread Performance Checker caused this issue? @shogo4405 @floriangbh I would love to learn about your troubleshooting approach. |
Beta Was this translation helpful? Give feedback.
-
Summary for future reference:
|
Beta Was this translation helpful? Give feedback.
-
Thank you for your response. I'm really curious about how you figured out that the Thread Performance Checker was causing the issue. I've spent a couple of days trying to track down the problem using tools like Memory Graph and Instruments' Allocation, but I failed to address the issue. I really admire your expertise, if would be great if you could share any methods or process on how you approached diagnosing this problem🙏 |
Beta Was this translation helpful? Give feedback.
Summary for future reference: