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().

Constructors

this
this(GMemChunk* gMemChunk)

Sets our main struct and passes it to the parent class

this
this(string name, int atomSize, gsize areaSize, int type)

Warning g_mem_chunk_new has been deprecated since version 2.10 and should not be used in newly-written code. Use the slice allocator instead Creates a new GMemChunk.

Members

Functions

alloc
void* alloc()

Warning g_mem_chunk_alloc has been deprecated since version 2.10 and should not be used in newly-written code. Use g_slice_alloc() instead Allocates an atom of memory from a GMemChunk.

alloc0
void* alloc0()

Warning g_mem_chunk_alloc0 has been deprecated since version 2.10 and should not be used in newly-written code. Use g_slice_alloc0() instead Allocates an atom of memory from a GMemChunk, setting the memory to 0.

clean
void clean()

Warning g_mem_chunk_clean has been deprecated since version 2.10 and should not be used in newly-written code. Use the slice allocator instead Frees any blocks in a GMemChunk which are no longer being used.

destroy
void destroy()

Warning g_mem_chunk_destroy has been deprecated since version 2.10 and should not be used in newly-written code. Use the slice allocator instead Frees all of the memory allocated for a GMemChunk.

free
void free(void* mem)

Warning g_mem_chunk_free has been deprecated since version 2.10 and should not be used in newly-written code. Use g_slice_free1() instead Frees an atom in a GMemChunk. This should only be called if the GMemChunk was created with G_ALLOC_AND_FREE. Otherwise it will simply return.

getMemoryChunkStruct
GMemChunk* getMemoryChunkStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

print
void print()

Warning g_mem_chunk_print 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 a GMemChunk. It outputs the name of the GMemChunk (set with g_mem_chunk_new()), the number of bytes used, and the number of blocks of memory allocated.

print
void print()
Undocumented in source. Be warned that the author may not have intended to support it.
print
void print()
Undocumented in source. Be warned that the author may not have intended to support it.
reset
void reset()

Warning g_mem_chunk_reset has been deprecated since version 2.10 and should not be used in newly-written code. Use the slice allocator instead Resets a GMemChunk to its initial state. It frees all of the currently allocated blocks of memory.

Static functions

blowChunks
void blowChunks()

Warning g_blow_chunks has been deprecated since version 2.10 and should not be used in newly-written code. Use the slice allocator instead Calls g_mem_chunk_clean() on all GMemChunk objects.

info
void info()

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.

Variables

gMemChunk
GMemChunk* gMemChunk;

the main Gtk struct

Meta