ThiagoFerrao / solum

APIs for OEMs to Create Standalone Applications
https://www.clarius.com
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Memory leak in SolumExample #6

Open ujrm opened 5 days ago

ujrm commented 5 days ago

Describe the bug As images are received from the probe, memory usage continues to increate as rawBytes is never dealocated.

https://github.com/ujrm/solum/blob/02fc7b6002e22e6712150a9c12e09e642801d4b8/examples/solum_swift/Shared/SolumModel.swift#L203

This happens because there's not an autorelease pool if it's not allocated from the main queue.

The solution is to add a deferred deallocation immediately after allocation :

defer {
    rawBytes.deallocate()
}

Bug is present in commit 02fc7b6 but fixed in f64cd39

To Reproduce Steps to reproduce the behavior:

  1. Tap Download scanner info
  2. Enable Bluetooth searching
  3. Select probe
  4. Tap Load Selected Scanner Details
  5. Connect to probe's WiFi
  6. Tap Connect
  7. Change Application to "msk"
  8. Tap Load Application
  9. Tap Run Imaging
  10. Monitor the memory usage from Xcode debugger

The allocations with no matching deallocations can also be noted from Instruments.

Environment:

clariusk commented 5 days ago

Looks related primarily to NN app, but @julien-l any comments appreciated?

julien-l commented 4 days ago

This is an issue with the example app, not with the SDK, I will update our examples with the fix, thanks.