Format
#include <stdlib.h> /* also in <malloc.h> */ void _tmalloc(size_t size);
Language Level: Extension
_tmalloc allocates tiled memory for an object of size size,
the value of which is indeterminate.
To use _tmalloc, you must compile with the /Gt compiler option. This option maps all malloc calls to _tmalloc.
Note: The /Gt option maps all calls to regular memory management functions to their tiled versions. To prevent a call from being mapped, parenthesize the function name.
_tmalloc works just like malloc except that it allocates tiled memory instead of regular memory. Tiled memory will not cross 64K boundaries, as long as the object is less than 64K in size. Objects larger than 64K in size are aligned on 64K boundaries, but will also cross 64K boundaries. If you have objects that may be accessed by 16-bit code, you should store them in tiled memory.
Tiled memory from the IBM C and C++ Compilers runtime heap is limited to 512 MB per process. You can also create your own heaps of tiled memory, which can be larger in size.
Memory allocated by _tmalloc can only be freed using _tfree.
A debug version of this function, _debug_tmalloc, is also available. Use the /Tm option to map all _tmalloc calls to _debug_tmalloc.
Return Value
_tmalloc returns a pointer to the allocated tiled
memory. If not enough storage is available, or if size
is 0, _tmalloc returns NULL.
Example
This example uses _tmalloc to allocate 100 bytes of
tiled memory.
Note: You must compile this example with the /Gt option to enable tiled memory.
#include <stdlib.h> #include <stdio.h>
int main(void)
{
char *memoryPtr;
if (NULL != (memoryPtr = (char*)malloc(100)))
puts("Successfully allocated 100 bytes of tiled memory.");
else
puts("Could not allocate tiled memory.");
free(memoryPtr);
return 0;
/***********************************************************
The output should be similar to:
Successfully allocated 100 bytes of tiled memory. ***********************************************************/ }
![]()
_debug_malloc -- Allocate Memory
_debug_tmalloc -- Reserve Tiled Memory
malloc -- Reserve Storage Block
_tcalloc -- Reserve Tiled Storage Block
_tdump_allocated -- Get Information about
Allocated Tiled Memory
_tdump_allocated_delta -- Get Information
about Allocated Tiled Memory
_tfree -- Free Tiled Storage Block
_trealloc -- Reallocate Tiled Storage Block
_umalloc -- Reserve Memory Blocks from
User Heap
<malloc.h>
<stdlib.h>
/Tm compiler option
/Gt compiler option