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 leak on mac m4 #203

Open
louis030195 opened this issue Mar 3, 2025 · 9 comments
Open

memory leak on mac m4 #203

louis030195 opened this issue Mar 3, 2025 · 9 comments
Labels
bug Something isn't working

Comments

@louis030195
Copy link
Contributor

i suspect there is a memory leak since 0.3.3 on macos at least, will try to share reproduction

@louis030195
Copy link
Contributor Author

https://github.com/louis030195/xcap-leak

# run the main.rs then 

ps aux | grep xcap

leaks 28292

Process 28292 is not debuggable. Due to security restrictions, leaks can only show or save contents of readonly memory of restricted processes.

Process:         xcap-leak [28292]
Path:            /Users/USER/Documents/*/xcap-leak
Load Address:    0x102c88000
Identifier:      xcap-leak
Version:         0
Code Type:       ARM64
Platform:        macOS
Parent Process:  Cursor Helper [65029]

Date/Time:       2025-03-03 15:53:31.763 -0800
Launch Time:     2025-03-03 15:51:40.578 -0800
OS Version:      macOS 15.3.1 (24D70)
Report Version:  7
Analysis Tool:   /Applications/Xcode.app/Contents/Developer/usr/bin/leaks
Analysis Tool Version:  Xcode 16.2 (16C5032a)

Physical footprint:         53.8M
Physical footprint (peak):  86.9M
Idle exit:                  untracked
----

leaks Report Version: 4.0
Process 28292: 4108 nodes malloced for 23866 KB
Process 28292: 229 leaks for 16448 total leaked bytes.

    229 (16.1K) << TOTAL >>

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x1036046b0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x103604700> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x103604770> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x1036047c0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x103704b00> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x103704b50> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x114e04080> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x114e04340> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x114e04100> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x114e04150> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x114e041c0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x114e04210> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x114e041f0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x114e042d0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x114e043b0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x114e04400> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x114e04470> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x114e044c0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x114f040d0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x114f041f0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x114f04100> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x114f04150> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x114f04120> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x114f04390> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x114f041c0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x114f04320> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x114f04260> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x114f042b0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x114f04400> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x114f04450> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x114f04550> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x114f045a0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124e04140> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124e04ce0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124e04170> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124e041c0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124e04190> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124e04560> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124e04280> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124e042d0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124e042a0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124e04420> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124e04340> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124e04c70> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124e04360> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124e043b0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124e04380> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124e044c0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124e04490> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124e04730> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124e04530> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124e04600> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124e045d0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124e04860> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124e04670> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124e046c0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124e047a0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124e047f0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124e047c0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124e04900> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124f040d0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124f041f0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124f04100> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124f04150> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124f04120> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124f04290> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x124f04350> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x124f043a0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x1258040d0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x1258041f0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x125804100> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x125804150> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x125804120> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x125804590> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x1258041c0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x125804290> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x125804260> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x125804330> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x1258043a0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x1258043f0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x1258043c0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x125804460> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x1258044d0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x125804520> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x125804600> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x125804650> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x1259040d0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x1259041f0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x125904100> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x125904150> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x125904120> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x125904520> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x1259041c0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x125904350> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x125904260> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x1259042b0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x125904280> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x1259043f0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x125904460> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x1259044b0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x127004100> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x127004150> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x127104af0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x127104b40> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144e06160> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144e05ce0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144e10de0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144e1aa70> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144e14a00> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144e10e00> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144e19160> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144e1acd0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144e1a880> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144e1ab30> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144e1a8a0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144e05d50> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144e1ad40> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144e1a720> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144e1ad90> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144e14990> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144f04430> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144f06190> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144f04dd0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144f06410> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144f04e90> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144f06480> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144f050d0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144f06050> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144f050f0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144f055f0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144f05d30> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144f063a0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144f05d60> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144f06120> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144f05da0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144f04e20> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144f06200> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144f05fe0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144f062b0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144f06300> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144f062d0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144f05510> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x144f06370> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x144f05580> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x1458074f0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14580c050> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145807520> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14580b300> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14580a2e0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14580da80> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14580b380> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14580c290> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14580c620> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14580daf0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14580c8f0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14580c180> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14580c910> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14580d330> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14580d3a0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14580d000> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14580da30> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14580d070> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14580da60> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14580c110> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x1459094d0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14591e0d0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14590aee0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14591e3a0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14590afb0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14591e410> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14590b770> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14591e060> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14590b860> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14591e140> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14591d690> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14591e5e0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14591d7b0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14591dfb0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14591e020> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14591e500> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14591e1b0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14591e680> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14591e4d0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14591e570> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x14591e650> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x14591e720> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145a08c80> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145a0fc30> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145a08ee0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145a09110> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145a09a90> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145a0fca0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145a09b90> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145a0f9b0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145a0c880> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145a0ff50> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145a0c990> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145a0fa20> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145a0fab0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145a0fd40> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145a0fdb0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145a0fe00> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145a0fe70> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145a10020> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145a0fe90> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145a0fee0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145a10190> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145a101e0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145c04a90> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145c05d90> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145c04ab0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145c06070> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145c053f0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145c05ed0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145c05410> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145c063e0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145c05450> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145c06760> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145c06040> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145c064e0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145c06150> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145c05e50> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145c06300> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145c060e0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145c06320> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145c06180> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x145c063c0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x145c057b0> [112]

      1 (32 bytes) ROOT LEAK: <NSMutableDictionary 0x144f05120> [32]

@louis030195
Copy link
Contributor Author

can't find NSMutableDictionary in source code, is it dependency?

@louis030195
Copy link
Contributor Author

@louis030195
Copy link
Contributor Author

issue present both on 0.4.0 and 0.3.3

@louis030195
Copy link
Contributor Author

AI says one of those:

https://github.com/nashaofu/xcap/blob/master/src/macos/impl_monitor.rs#L29

The leak happens when calling screen.deviceDescription(). That method returns an autoreleased <NSMutableDictionary> which isn’t drained because there’s no autorelease pool in this code block. Wrap those calls in an autorelease pool to fix it.

let cf_array = match CGWindowListCopyWindowInfo(

The leak comes from the CFArray returned by CGWindowListCopyWindowInfo – it isn’t released, so the underlying NSMutableDictionary objects leak.

@ologbonowiwi
Copy link
Contributor

Tested it here, it was not introduced lately. Version 0.2.0 has the leak.

@ologbonowiwi
Copy link
Contributor

Both those options you mentioned are using Retain type, which should drop the values.

See on objc2 docs: https://docs.rs/objc2/latest/objc2/rc/struct.Retained.html and https://docs.rs/objc2-core-foundation/latest/objc2_core_foundation/struct.CFRetained.html

@ologbonowiwi
Copy link
Contributor

Went as deep as I could on this rabbit hole. Version 0.0.1 has the leak.

Process 48460 is not debuggable. Due to security restrictions, leaks can only show or save contents of readonly memory of restricted processes.

^R
Process:         xcap-leak [48460]
Path:            /Users/USER/*/xcap-leak
Load Address:    0x100884000
Identifier:      xcap-leak
Version:         0
Code Type:       ARM64
Platform:        macOS
Parent Process:  zsh [79093]

Date/Time:       2025-03-03 21:30:10.331 -0300
Launch Time:     2025-03-03 21:29:44.581 -0300
OS Version:      macOS 15.3.1 (24D70)
Report Version:  7
Analysis Tool:   /Applications/Xcode.app/Contents/Developer/usr/bin/leaks
Analysis Tool Version:  Xcode 16.2 (16C5032a)

Physical footprint:         11.8M
Physical footprint (peak):  96.9M
Idle exit:                  untracked
----

leaks Report Version: 4.0
Process 48460: 4640 nodes malloced for 30164 KB
Process 48460: 33 leaks for 2560 total leaked bytes.

    33 (2.50K) << TOTAL >>
      1 (256 bytes) ROOT LEAK: <CFArray 0x600002834100> [256]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x6000014188c0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x600003f24150> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x6000014188e0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x600003f241c0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x600001418920> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x600003f242a0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x600001418960> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x600003f24070> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x60000141c260> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x600003f1c000> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x60000141c2a0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x600003f1c070> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x60000141c2c0> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x600003f1c0e0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x600001420020> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x600003f18000> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x600001430100> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x600003f38460> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x600001430140> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x600003f383f0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x600001430160> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x600003f384d0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x600001430180> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x600003f38380> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x600001430300> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x600003f38540> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x600001430380> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x600003f38620> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x600001434d40> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x600003f341c0> [112]

      2 (144 bytes) ROOT LEAK: <NSMutableDictionary 0x60000143a140> [32]
         1 (112 bytes) <NSMutableDictionary (Storage) 0x600003f20d20> [112]

@nashaofu nashaofu added the bug Something isn't working label Mar 4, 2025
@nashaofu
Copy link
Owner

Is this issue only present in the ARM version?

Process:         xcap-leak [3054]
Path:            /Users/USER/Downloads/*/xcap-leak
Load Address:    0x10df08000
Identifier:      xcap-leak
Version:         0
Code Type:       X86-64
Platform:        macOS
Parent Process:  zsh [1057]

Date/Time:       2025-03-12 08:42:22.888 +0800
Launch Time:     2025-03-12 08:41:22.472 +0800
OS Version:      macOS 15.3.1 (24D70)
Report Version:  7
Analysis Tool:   /Applications/Xcode.app/Contents/Developer/usr/bin/leaks
Analysis Tool Version:  Xcode 16.2 (16C5032a)

Physical footprint:         6000K
Physical footprint (peak):  12.2M
Idle exit:                  untracked
----

leaks Report Version: 4.0
Process 3054: 3609 nodes malloced for 591 KB
Process 3054: 0 leaks for 0 total leaked bytes.

@louis030195 louis030195 changed the title memory leak since 0.3.3 memory leak on mac m4 Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants