Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Free Function
Collapse the table of content
Expand the table of content

Free Function

Frees a block of memory previously allocated by the Alloc method to the Concurrency Runtime's Caching Suballocator.

_CRTIMP void __cdecl Free(
   void * _PAllocation


A pointer to memory previously allocated by the Alloc method which is to be freed. If the parameter _PAllocation is set to the value NULL, this method will ignore it and return immediately.

Use the caching suballocator when you expect to make several allocations interspersed with deallocations with a small set of block sizes on a number of threads. The suballocator is a caching layer above the C Runtime heap. The Concurrency Runtime creates a suballocator per virtual processor in a scheduler, as well as one sub allocator per thread created by your application that uses the allocator methods.

Once you have built up a cache of a certain size block, allocations and frees are possible without holding locks or even executing memory barriers. If the cache in each suballocator for a block size is empty, allocations are made from the heap, and if the cache has reached a certain size for a block size, the blocks are free to the C Runtime heap.

If your application uses a large amount of memory you may find that you run out of memory sooner than you exepct if you use the caching suballocator. This is because blocks cached in one suballocator are not available to another, and there may be large amounts of memory cached in suballocators that a particular thread has no access to at a particular point.

Header: concrt.h

Namespace: Concurrency

Community Additions

© 2015 Microsoft