I am currently working on Conway's Game of Life simulator for iPhone, and I had a few questions about memory management. Please note that I am using ARC.
For my application, I will need a large number of C style structsor Objective-C objects to represent cells. There may be several thousand of them, so it is obvious that memory management came to mind. My argument for structures is that the cells do not require typical OO properties. The only thing they will hold is two meanings
structsBOOL, therefore, there will not be a huge amount of memory chewed by these cells. In addition, I need to use a two-dimensional array. With structs, I can use 2-dimensional C-style arrays. To my knowledge, there is no substitute for this in Objective-C. I feel that it is too difficult to create an object for only two Boolean values.
Objective-C objects My argument (and most other people) is that managing memory around Objective-C objects is very simple and efficient with ARC. In addition, I saw the arguments that a is structnot such a large memory reduction for an object.
So my question. Should I go with the old school, skinny and compatible with a two-dimensional array structs? Or should I stick with typical Objective-C objects and risk using extra memory.
Follow-up thoughts: If you recommend Objective-C objects, provide an alternative storage method, which is a two-dimensional array. This is critical and is one of the biggest drawbacks of transitioning with Objective-C objects.
Thankyou.
source
share