How to remove a 2D array in Objective-C (cocoa)

I want to have a simple 2D C array like x[ 10][20] ; and I want to delete it when necessary to free memory, but cocoa does not have a delete method. What is the best way? (Also like a performance issue)

+4
source share
1 answer

You are not freeing your memory because the memory was allocated on the stack by simply declaring your array. Then the memory will be freed upon exiting the method. You should free your memory, though if it was allocated on the heap using the C malloc function.

Take a look at this doc . This explains everything related to C memory management.

+2
source

Source: https://habr.com/ru/post/1434085/


All Articles