glib.MemoryChunk

Undocumented in source.

Public Imports

gtkc.glibtypes
public import gtkc.glibtypes;
Undocumented in source.

Members

Classes

MemoryChunk
class MemoryChunk

Description Memory chunks provide an space-efficient way to allocate equal-sized pieces of memory, called atoms. However, due to the administrative overhead (in particular for G_ALLOC_AND_FREE, and when used from multiple threads), they are in practise often slower than direct use of g_malloc(). Therefore, memory chunks have been deprecated in favor of the slice allocator, which has been added in 2.10. All internal uses of memory chunks in GLib have been converted to the g_slice API. There are two types of memory chunks, G_ALLOC_ONLY, and G_ALLOC_AND_FREE. G_ALLOC_ONLY chunks only allow allocation of atoms. The atoms can never be freed individually. The memory chunk can only be free in its entirety. G_ALLOC_AND_FREE chunks do allow atoms to be freed individually. The disadvantage of this is that the memory chunk has to keep track of which atoms have been freed. This results in more memory being used and a slight degradation in performance. To create a memory chunk use g_mem_chunk_new() or the convenience macro g_mem_chunk_create(). To allocate a new atom use g_mem_chunk_alloc(), g_mem_chunk_alloc0(), or the convenience macros g_chunk_new() or g_chunk_new0(). To free an atom use g_mem_chunk_free(), or the convenience macro g_chunk_free(). (Atoms can only be freed if the memory chunk is created with the type set to G_ALLOC_AND_FREE.) To free any blocks of memory which are no longer being used, use g_mem_chunk_clean(). To clean all memory chunks, use g_blow_chunks(). To reset the memory chunk, freeing all of the atoms, use g_mem_chunk_reset(). To destroy a memory chunk, use g_mem_chunk_destroy(). To help debug memory chunks, use g_mem_chunk_info() and g_mem_chunk_print().

Meta