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.

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.

the size, in bytes, of each block of memory allocated to contain
the atoms.

type :

the type of the GMemChunk.
G_ALLOC_AND_FREE is used if the atoms will be freed individually.
G_ALLOC_ONLY should be used if atoms will never be freed individually.
G_ALLOC_ONLY is quicker, since it does not need to track free atoms,
but it obviously wastes memory if you no longer need many of the atoms.

g_mem_chunk_create()

#define g_mem_chunk_create(type, pre_alloc, alloc_type)

Warning

g_mem_chunk_create has been deprecated since version 2.10 and should not be used in newly-written code. Use the slice
allocator instead

A convenience macro for creating a new GMemChunk.
It calls g_mem_chunk_new(), using the given type to create the GMemChunk
name. The atom size is determined using sizeof(), and the
area size is calculated by multiplying the pre_alloc parameter with
the atom size.

type :

the type of the atoms, typically a structure name.

pre_alloc :

the number of atoms to store in each block of memory.

alloc_type :

the type of the GMemChunk.
G_ALLOC_AND_FREE is used if the atoms will be freed individually.
G_ALLOC_ONLY should be used if atoms will never be freed individually.
G_ALLOC_ONLY is quicker, since it does not need to track free atoms,
but it obviously wastes memory if you no longer need many of the atoms.

Warning

g_mem_chunk_info ()

void g_mem_chunk_info (void);

Warning

g_mem_chunk_info has been deprecated since version 2.10 and should not be used in newly-written code. Use the slice
allocator instead

Outputs debugging information for all GMemChunk objects currently in use.
It outputs the number of GMemChunk objects currently allocated,
and calls g_mem_chunk_print() to output information on each one.