C# Class GAudio.GATDataAllocator

Pre-allocates a large float[] to use as virtual memory and avoid any garbage collection. All calls to GATActiveSampleBank and GATReamplingSampleBank GetProcessedSample methods result in a virtual allocation from GATManager's default GATDataAllocator instance.
Inheritance: IDisposable
显示文件 Open project: gregzo/G-Audio Class Usage Examples

Public Methods

Method Description
CleanUp ( ) : void
Defragment ( ) : void

Defragments contiguous free chunks. Automatically called when a chunk of appropriate size cannot be recycled.

Dispose ( ) : void
GATDataAllocator ( InitializationSettings initSettings ) : System

Initializes a new instance of the GATDataAllocator class. In most cases, only the default allocator initialized by GATManager is required.

GetDataContainer ( int size ) : GATData

Finds and virtually allocates a GATManagedData instance before returning it as a GATData reference. First, the algorithm looks at the free chunks bin of appropriate size. If the bin doesn't hold any chunk, it will check if there is enough unfragmented space. If there isn't, it will look at bins holding larger chunks and fragment one if found. Finally, it will attempt defragmenting and run again, before logging an out of memory error.

GetDebugInfo ( ) : List

Gets information regarding each allocated chunk.

GetFixedDataContainer ( int size, string description ) : GATData

Allocates a fixed chunk of memory. Fixed chunks cannot be freed, but may be of any size. For debugging ease, a description is required when requesting a fixed chunk.

GetFixedDebugInfo ( ) : List

Gets information regarding fixed allocations.

NbOfAvailableChunksForSize ( int size ) : int

A conservative estimate of the available number of chunks. Takes into account both unfragmented memory and recyclable previously allocated chunks.

Private Methods

Method Description
AddToFreeChunksBins ( GATManagedData chunk ) : void
Dispose ( bool explicitly ) : void
GetBinIndexForSize ( int size ) : int
GetOrMakeChunk ( ) : GATManagedData
InitCursors ( ) : void
TryFragmentBins ( int fromBinIndex, int binSize, GATManagedData &chunk ) : bool

Method Details

CleanUp() public method

public CleanUp ( ) : void
return void

Defragment() public method

Defragments contiguous free chunks. Automatically called when a chunk of appropriate size cannot be recycled.
public Defragment ( ) : void
return void

Dispose() public method

public Dispose ( ) : void
return void

GATDataAllocator() public method

Initializes a new instance of the GATDataAllocator class. In most cases, only the default allocator initialized by GATManager is required.
public GATDataAllocator ( InitializationSettings initSettings ) : System
initSettings InitializationSettings
return System

GetDataContainer() public method

Finds and virtually allocates a GATManagedData instance before returning it as a GATData reference. First, the algorithm looks at the free chunks bin of appropriate size. If the bin doesn't hold any chunk, it will check if there is enough unfragmented space. If there isn't, it will look at bins holding larger chunks and fragment one if found. Finally, it will attempt defragmenting and run again, before logging an out of memory error.
public GetDataContainer ( int size ) : GATData
size int /// Size of the chunk to virtually allocate. ///
return GATData

GetDebugInfo() public method

Gets information regarding each allocated chunk.
public GetDebugInfo ( ) : List
return List

GetFixedDataContainer() public method

Allocates a fixed chunk of memory. Fixed chunks cannot be freed, but may be of any size. For debugging ease, a description is required when requesting a fixed chunk.
public GetFixedDataContainer ( int size, string description ) : GATData
size int
description string
return GATData

GetFixedDebugInfo() public method

Gets information regarding fixed allocations.
public GetFixedDebugInfo ( ) : List
return List

NbOfAvailableChunksForSize() public method

A conservative estimate of the available number of chunks. Takes into account both unfragmented memory and recyclable previously allocated chunks.
public NbOfAvailableChunksForSize ( int size ) : int
size int
return int