StandardCyborg / StandardCyborgCocoa

Everything you need for 3D scanning on iOS
https://www.standardcyborg.com
Other
143 stars 49 forks source link

Memory allocation increases with each new scan #34

Closed Jaykob closed 1 year ago

Jaykob commented 1 year ago

Hi! First thanks for this great project! :) I'm running into memory issues when I do several scan sessions in succession. When profiling my app I can see that memory allocation increases with each new scan but never goes down again. Am I the only one with this problem or am I doing something wrong on my side?

scratchthatitch commented 1 year ago

We will need more information to help. Are you saving them to your directory? Are you saving them intentionally or by accident. Do you know where you are saving them?

[Image]https://fyous.com/ @.*** 07983403383

UNIT 14, CARLISLE BUSINESS PARK 40 CHAMBERS LANE, SHEFFIELD, S4 8DAhttp://maps.apple.com/?q=UNIT%2014,%20CARLISLE%20BUSINESS%20PARK,40%20CHAMBERS%20LANE,%20SHEFFIELD,%20S4%208DA

[Facebook]https://www.facebook.com/fyouswear[LinkedIn (Company)]https://www.linkedin.com/company/fyous[Instagram]https://www.instagram.com/fyous_official/[YouTube]https://www.youtube.com/channel/UCUPncfoAknDndW7zVKR6m6g[Twitter]https://twitter.com/Fyous_Official

FYOUS.COMhttps://fyous.com/

The content of this email is confidential and intended for the recipient specified in message only. It is strictly forbidden to share any part of this message with any third party, without a written consent of the sender. If you received this message by mistake, please reply to this message and follow with its deletion, so that we can ensure such a mistake does not occur in the future.


From: Jaykob @.> Sent: Thursday, April 20, 2023 4:37:00 PM To: StandardCyborg/StandardCyborgCocoa @.> Cc: Subscribed @.***> Subject: [StandardCyborg/StandardCyborgCocoa] Memory issues (Issue #34)

Hi! First thanks for this great project! :) I'm running into memory issues when I do several scan sessions in succession. When profiling my app I can see that memory allocation increases with each new scan but never goes down again. Am I the only one with this problem or am I doing something wrong on my side?

— Reply to this email directly, view it on GitHubhttps://github.com/StandardCyborg/StandardCyborgCocoa/issues/34, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANS2IX2UUTQPEOSIEELGWD3XCFJZZANCNFSM6AAAAAAXFVY75U. You are receiving this because you are subscribed to this thread.Message ID: @.***>

Jaykob commented 1 year ago

Yes, I'm saving them to the app's document directory intentionally using our own method, including normals and color information. Anything I have to consider here memory wise?

scratchthatitch commented 1 year ago

Ok. Can you expand more on the memory issue? Define issue.


From: Jaykob @.> Sent: 21 April 2023 08:28 To: StandardCyborg/StandardCyborgCocoa @.> Cc: Joshua Shires @.>; Comment @.> Subject: Re: [StandardCyborg/StandardCyborgCocoa] Memory issues (Issue #34)

Yes, I'm saving them to the app's document directory intentionally using our own method, including normals and color information. Anything I have to consider here memory wise?

— Reply to this email directly, view it on GitHubhttps://github.com/StandardCyborg/StandardCyborgCocoa/issues/34#issuecomment-1517392564, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANS2IXZFE7KIV4BTFH2TUL3XCIZLJANCNFSM6AAAAAAXFVY75U. You are receiving this because you commented.Message ID: @.***>

Jaykob commented 1 year ago

Memory consumption increases with each scan until the app finally crashes. It looks to me as if memory isn’t freed at some point. This could only be in the C++ part though, right? Instruments doesn’t show any leaks.

scratchthatitch commented 1 year ago

If every scan is being saved, then yes, eventually you will exceed some kind of limit. If you are scanning large objects, each scan can be a lot of data.

You will need to monitor how many scans you are saving and then delete them at some point to free up memory.

Unless you are talking about a memory leak where the scan is being saved repeatedly unintentionally.

Sorry If I misunderstood your issue. The more details you can provide, the better the community can help.


From: Jaykob @.> Sent: 21 April 2023 20:44 To: StandardCyborg/StandardCyborgCocoa @.> Cc: Joshua Shires @.>; Comment @.> Subject: Re: [StandardCyborg/StandardCyborgCocoa] Memory issues (Issue #34)

Memory consumption increases with each scan until the app finally crashes. It looks to me as if memory isn’t freed at some point. This could only be in the C++ part though, right?

— Reply to this email directly, view it on GitHubhttps://github.com/StandardCyborg/StandardCyborgCocoa/issues/34#issuecomment-1518263613, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANS2IXZYGYYMSSCCEIX77DTXCLPRFANCNFSM6AAAAAAXFVY75U. You are receiving this because you commented.Message ID: @.***>

Jaykob commented 1 year ago

Thanks for your help!

Why would saving to the file system (App’s document directory) increase memory consumption?

How would I delete the scans to free memory?

aaptho commented 1 year ago

Yes, this certainly sounds like a memory leak or abandonment, not an issue with file saving.

To help diagnose, would you mind sharing an Instruments trace with the Leaks and Allocations instruments? Ideally I’d like to see a generation analysis, which can track down memory that’s abandoned and not just leaked. To do so, with Allocations selected, click Mark Generation, do a scan, close the scan, click Mark Generation, and repeat a couple more times. Here’s a nice tutorial on that if you’re not already familiar! https://www.kodeco.com/16126261-instruments-tutorial-with-swift-getting-started#toc-anchor-008

Jaykob commented 1 year ago

OK so it turned out that we had a bug in our app lifecycle and the memory issue only appeared to be stemming from StandardCyborg 😅 Sorry for that. I'm going to close this issue.