diff vmalloc.c @ 140:2c8f3cf6c058

Free memory calculation
author Merten Sach <msach@mailbox.tu-berlin.de>
date Mon, 19 Sep 2011 18:43:08 +0200
parents 99798e4438a6
children 79bb48d7d93b
line diff
     1.1 --- a/vmalloc.c	Mon Sep 19 16:12:01 2011 +0200
     1.2 +++ b/vmalloc.c	Mon Sep 19 18:43:08 2011 +0200
     1.3 @@ -15,6 +15,7 @@
     1.4  #include <math.h>
     1.5  
     1.6  #include "VMS.h"
     1.7 +#include "vmalloc.h"
     1.8  #include "Histogram/Histogram.h"
     1.9  
    1.10  #define MAX_UINT64 0xFFFFFFFFFFFFFFFF
    1.11 @@ -106,7 +107,7 @@
    1.12     {
    1.13         //Find the approppiate container because we do not know it
    1.14         uint64 containerIdx = ((uintptr_t)chunk->prevChunkInFreeList - (uintptr_t)freeLists->bigChunks) >> 3;
    1.15 -       if(containerIdx < (uint32)64)
    1.16 +       if(containerIdx < (uint64)64)
    1.17             freeLists->bigChunksSearchVector[0] &= ~((uint64)1 << containerIdx); 
    1.18         if(containerIdx < 128 && containerIdx >=64)
    1.19             freeLists->bigChunksSearchVector[1] &= ~((uint64)1 << (containerIdx-64)); 
    1.20 @@ -251,9 +252,10 @@
    1.21         else
    1.22             foundChunk = removeSmallChunk(freeLists, freeListIdx);
    1.23         
    1.24 +       _VMSMasterEnv->amtOfOutstandingMem -= getChunkSize(foundChunk) + sizeof(MallocProlog);
    1.25         returnChunk = (MallocPrologAllocated*)foundChunk;
    1.26         returnChunk->prevChunkInFreeList = NULL;//indicates elem currently allocated
    1.27 -       returnChunk->procrID = procrID;  
    1.28 +       returnChunk->procrID = procrID;
    1.29         return returnChunk + 1;
    1.30     }
    1.31     
    1.32 @@ -267,6 +269,7 @@
    1.33         foundChunk = removeChunk(freeLists, containerIdx); 
    1.34     
    1.35     //Mark as allocated
    1.36 +   _VMSMasterEnv->amtOfOutstandingMem -= getChunkSize(foundChunk) + sizeof(MallocProlog);
    1.37     returnChunk = (MallocPrologAllocated*)foundChunk;
    1.38     returnChunk->prevChunkInFreeList = NULL;//indicates elem currently allocated
    1.39     returnChunk->procrID = procrID;
    1.40 @@ -372,6 +375,7 @@
    1.41     MallocArrays* freeLists = _VMSMasterEnv->freeLists[procrID];
    1.42     MallocProlog *chunkToFree = (MallocProlog*)ptrToFree - 1;
    1.43     uint32 containerIdx;
    1.44 +   _VMSMasterEnv->amtOfOutstandingMem += getChunkSize(chunkToFree) + sizeof(MallocProlog);
    1.45     
    1.46     //Check for free neighbors
    1.47     if(chunkToFree->nextLowerInMem)