[미지근한 완료]윈도우, 리눅스, 맥에서 사용하는 할당/해제 함수는?

hiluciano의 이미지

할당/해제를 수행하는 함수가 윈도우에서는

HeapCreate, HeapAlloc, HeapReAlloc, HeapFree, HeapDestroy
GlobalAlloc, GlobalLock, GlobalReAlloc, GlobalUnlock, GlobalDiscard
LocalAlloc, LocalLock, LocalReAlloc, LocalUnlock, LocalDiscard
VirtualAlloc, VirtualLock, VirtualUnLock, VirtualFree

그리고 그 유명한 malloc/calloc, realloc, free

그런데 리눅스나 맥에서는 어떤 할당/해제 함수를 제공하나요?
그리고 WINAPI에서 이거 말고 또 다른 메모리 함수 있나요?

superwtk의 이미지

Mac OSX (또는 iPhone) 의 Cocoa Framework 에서는 alloc 과 retain, release 또는 autorelease 를 사용합니다. retain count 가 0 이 되면 해당 객체의 dealloc 함수가 호출됩니다.

예제

NSView *view = [[NSView alloc] initWithFrame:CGRectZero];
[view release];
 
NSString *string = [NSString stringWithFormat:@"1 + 1 = %d", 1+1];
return [string retain];
 
UITableCell *cell = [[[UITableCell alloc] initWithFrame:CGRectZero] autorelease];
return cell;

--------------------------------------------------------------------------------
http://blog.sumin.us

Necromancer의 이미지

linux라면

man mmap
man munmap
man brk
man sbrk

malloc(), free(), callo() 모두 이들을 편하게 사용하기 위한 wrapper함수입니다. 알고리즘은 좀 복잡하긴 하지만.

Written By the Black Knight of Destruction

Written By the Black Knight of Destruction