Reputation: 9351
I'm trying to find a way of limiting the amount of memory a particular custom object is using, based on how much memory is left. The most useful way of doing this would be some kind of method or function that checks to see how much memory a given C Object is using. This way the program can reject the creation of further data when the object reaches its preset limit, rather than going ahead and creating it then dealing with the memory warning in retrospect.
Does anyone know of Cocoa methods that: A) Return how much memory is being used by a given object B) Return how much more memory the system can use up before it generates a warning
-Ash
Upvotes: 1
Views: 1650
Reputation: 16709
A. You can get size of an object using malloc_size(myObject)
(you need to traverse all the nested objects too). Also check docs for NSCache.
B. No, there is no documented way to do that
Upvotes: 4