A class for managing memory zones. More...
#import <Foundation/Foundation.h>
Instance Methods | |
(void) | - dealloc |
Deallocates the memory zone. More... | |
(void *) | - allocWithSize: |
Allocates a block of memory from the zone. More... | |
(void) | - free: |
Frees a block of memory that was allocated from the zone. More... | |
(void) | - dump |
Walks through the zone and outputs information about allocations. More... | |
(size_t) | - bytesTotal |
Returns the total size of the memory zone. More... | |
(size_t) | - bytesUsed |
Returns the used size of the memory zone. More... | |
(size_t) | - bytesFree |
Returns the free size of the memory zone. More... | |
![]() | |
(id) | - retain |
Increases the retain count of the receiver. More... | |
(void) | - release |
Decreases the retain count of the receiver. More... | |
(id) | - autorelease |
Adds the receiver to the autorelease pool. | |
![]() | |
(id) | - init |
Initialize the instance, after allocation. More... | |
(Class) | - class |
Returns the class of the instance. More... | |
(Class) | - superclass |
Returns the superclass of the instance. More... | |
(BOOL) | - isEqual: |
Compares the receiver to another object for equality. More... | |
(BOOL) | - isKindOfClass: |
Returns a Boolean value that indicates whether the receiver is an instance of a given class. More... | |
(BOOL) | - conformsTo: |
Checks if the receiver's class conforms to a protocol. More... | |
(NXString *) | - description |
Returns a string that represents the instance. More... | |
![]() | |
(BOOL) | - respondsToSelector: |
Checks if the receiver responds to a selector. More... | |
Class Methods | |
(id) | + defaultZone |
Returns the default memory zone. More... | |
(id) | + zoneWithSize: |
Creates a new memory zone with a specified size. More... | |
![]() | |
(id) | + allocWithZone: |
Allocates a new instance of an object in a specific memory zone. More... | |
![]() | |
(void) | + initialize |
Performs one-time initialization for the class. More... | |
(id) | + alloc |
Allocate a new class instance. More... | |
(Class) | + class |
Returns the class object. More... | |
(Class) | + superclass |
Returns the superclass of the class. More... | |
(const char *) | + name |
Returns the name of the class. More... | |
(BOOL) | + conformsTo: |
Checks if the class conforms to a protocol. More... | |
(NXString *) | + description |
Returns a string that represents the class. More... | |
Protected Attributes | |
size_t | _size |
Initial allocated size of the memory zone in bytes. | |
size_t | _count |
Current number of active allocations in the zone. | |
![]() | |
id | _zone |
The memory zone where the object is allocated. | |
unsigned short | _retain |
The retain count of the object. | |
id | _next |
The next object in an autorelease pool. | |
![]() | |
Class | isa |
A pointer to the object's class structure. More... | |
A class for managing memory zones.
NXZone provides a mechanism for managing memory allocations. It can be used to create memory arenas of a fixed size, from which objects can be allocated.
- (void *) allocWithSize: | (size_t) | size |
Allocates a block of memory from the zone.
size | The number of bytes to allocate. |
- (size_t) bytesFree |
Returns the free size of the memory zone.
This method returns the number of free bytes in the memory zone.
- (size_t) bytesTotal |
Returns the total size of the memory zone.
This method returns the total capacity of the memory zone in bytes. Note that this includes both used and free memory, plus the size of the NXZone object itself.
- (size_t) bytesUsed |
Returns the used size of the memory zone.
This method returns the number of used bytes in the memory zone.
- (void) dealloc |
- (void) dump |
Walks through the zone and outputs information about allocations.
This method iterates through all allocations in the zone and prints their addresses and sizes to the log.
- (void) free: | (void *) | ptr |
Frees a block of memory that was allocated from the zone.
ptr | A pointer to the memory block to be deallocated. |
+ (id) zoneWithSize: | (size_t) | size |
Creates a new memory zone with a specified size.
size | The size of the memory zone with initial capacity in bytes. |
This method initializes a new memory zone with the specified capacity in bytes. The zone will be expanded as needed to accommodate additional requirements.