Is there a setting that limits how much free memory a C++ library can see?

I am trying to use the DuckDB library in a SwiftUI app. It does not seem to be able to allocate as much memory as it is available to it, and I was wondering if there is any setting I can tweak. I've logged the issue in their GitHub repo too, with full details.

Answered by DTS Engineer in 814422022

Library code runs within your process. All the code running in your process — so your app and all the libraries it uses — has the same privileges as far as the OS is concerned. So, a library you link to can allocate as much memory as your app [1].

As to why this library is behaving the way it is, it’s hard to say without looking at the code. If you can isolate this to a point where Apple code is doing something unexpected, I’d be happy to take a look.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Memory allocation comes in two forms:

  • Address space

  • Physical pages that back that address space.

iOS and visionOS put limits on both. However, this statement is true for both, so I’m using “memory” as a shorthand.

Accepted Answer

Library code runs within your process. All the code running in your process — so your app and all the libraries it uses — has the same privileges as far as the OS is concerned. So, a library you link to can allocate as much memory as your app [1].

As to why this library is behaving the way it is, it’s hard to say without looking at the code. If you can isolate this to a point where Apple code is doing something unexpected, I’d be happy to take a look.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Memory allocation comes in two forms:

  • Address space

  • Physical pages that back that address space.

iOS and visionOS put limits on both. However, this statement is true for both, so I’m using “memory” as a shorthand.

Is there a setting that limits how much free memory a C++ library can see?
 
 
Q