-block allocator now track allocated blocks and is able to free memory
-jobs data is now allocated in System struct -written memory cleanup (AddressSanitizer don't show any leak)
This commit is contained in:
parent
9824b587fb
commit
235bbb49f2
7 changed files with 214 additions and 41 deletions
|
|
@ -175,15 +175,7 @@ struct EventManager
|
|||
|
||||
void allocateData(uint threads_count) nothrow @nogc
|
||||
{
|
||||
if(events)
|
||||
{
|
||||
foreach(ref event;events)
|
||||
{
|
||||
Mallocator.instance.dispose(event.blocks);
|
||||
Mallocator.instance.dispose(event.first_blocks);
|
||||
}
|
||||
Mallocator.instance.dispose(events);
|
||||
}
|
||||
disposeData();
|
||||
events = Mallocator.instance.makeArray!EventData(gEM.events.length);
|
||||
foreach(i,ref event;events)
|
||||
{
|
||||
|
|
@ -196,8 +188,44 @@ struct EventManager
|
|||
}
|
||||
}
|
||||
|
||||
private void disposeData() nothrow @nogc
|
||||
{
|
||||
if(events)
|
||||
{
|
||||
foreach(ref event;events)
|
||||
{
|
||||
foreach(first_block; event.first_blocks)
|
||||
{
|
||||
EventBlock* block = first_block;
|
||||
EventBlock* next_block;
|
||||
if(block)next_block = first_block.next;
|
||||
while(block)
|
||||
{
|
||||
Mallocator.instance.dispose(block);
|
||||
block = next_block;
|
||||
if(block)next_block = block.next;
|
||||
}
|
||||
}
|
||||
|
||||
Mallocator.instance.dispose(event.blocks);
|
||||
Mallocator.instance.dispose(event.first_blocks);
|
||||
}
|
||||
Mallocator.instance.dispose(events);
|
||||
}
|
||||
allocator.freeMemory();
|
||||
}
|
||||
|
||||
~this() nothrow @nogc
|
||||
{
|
||||
disposeData();
|
||||
/*foreach(i,ref event;events)
|
||||
{
|
||||
EventBlock* block = event.first_blocks;
|
||||
}*/
|
||||
}
|
||||
|
||||
///Single page size. Must be power of two.
|
||||
enum events_block_size = 1 << 12;
|
||||
enum events_block_size = 1 << 14;
|
||||
///Number of pages in block.
|
||||
enum events_blocks_in_allocation = 128;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue