简体   繁体   中英

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

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

You don't free your memory because the memory was allocated on the stack by just declaring your array. Memory will then be freed when leaving the method. You should free your memory though if is was allocated on the heap using the C malloc function.

Have a look to this doc . This explains everything about C memory management.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM