diff --git a/src/Init.cpp b/src/Init.cpp index 5c2fff0c..cad96d3c 100644 --- a/src/Init.cpp +++ b/src/Init.cpp @@ -28,8 +28,6 @@ void InitConstants(); void InitDebugFiles(); -void FreeThreadMem(); - int lho[DDS_HANDS] = { 1, 2, 3, 0 }; int rho[DDS_HANDS] = { 3, 0, 1, 2 }; @@ -352,7 +350,7 @@ void InitConstants() void InitDebugFiles() { - for (unsigned thrId = 0; thrId < sysdep.NumThreads(); thrId++) + for (unsigned thrId = 0; thrId < memory.NumThreads(); thrId++) { ThreadData * thrp = memory.GetPtr(thrId); UNUSED(thrp); // To avoid compile errors @@ -392,7 +390,7 @@ void InitDebugFiles() void CloseDebugFiles() { - for (unsigned thrId = 0; thrId < sysdep.NumThreads(); thrId++) + for (unsigned thrId = 0; thrId < memory.NumThreads(); thrId++) { ThreadData * thrp = memory.GetPtr(thrId); UNUSED(thrp); // To avoid compiler warning @@ -597,16 +595,9 @@ void STDCALL GetDDSInfo(DDSInfo * info) } -void FreeThreadMem() -{ - for (unsigned thrId = 0; thrId < sysdep.NumThreads(); thrId++) - memory.ResetThread(thrId); -} - - void STDCALL FreeMemory() { - for (unsigned thrId = 0; thrId < sysdep.NumThreads(); thrId++) + for (unsigned thrId = 0; thrId < memory.NumThreads(); thrId++) memory.ReturnThread(thrId); } diff --git a/src/Memory.cpp b/src/Memory.cpp index f333d01f..62e8dcc1 100644 --- a/src/Memory.cpp +++ b/src/Memory.cpp @@ -13,25 +13,12 @@ Memory::Memory() { - Memory::Reset(); } Memory::~Memory() { -} - - -void Memory::Reset() -{ - nThreads = 0; -} - - -void Memory::ResetThread(const unsigned thrId) -{ - memory[thrId]->transTable->ResetMemory(TT_RESET_FREE_MEMORY); - memory[thrId]->memUsed = Memory::MemoryInUseMB(thrId); + Memory::Resize(0, DDS_TT_SMALL, 0, 0); } @@ -48,15 +35,14 @@ void Memory::Resize( const int memDefault_MB, const int memMaximum_MB) { - if (nThreads == n) + if (memory.size() == n) return; - if (nThreads > n) + if (memory.size() > n) { // Downsize. - for (unsigned i = n; i < nThreads; i++) + for (unsigned i = n; i < memory.size(); i++) { - memory[i]->transTable->ReturnAllMemory(); delete memory[i]->transTable; delete memory[i]; } @@ -66,9 +52,10 @@ void Memory::Resize( else { // Upsize. + unsigned oldSize = memory.size(); memory.resize(n); threadSizes.resize(n); - for (unsigned i = nThreads; i < n; i++) + for (unsigned i = oldSize; i < n; i++) { memory[i] = new ThreadData; if (flag == DDS_TT_SMALL) @@ -88,22 +75,20 @@ void Memory::Resize( memory[i]->transTable->MakeTT(); } } - - nThreads = n; } -int Memory::NumThreads() const +unsigned Memory::NumThreads() const { - return static_cast(nThreads); + return static_cast(memory.size()); } ThreadData * Memory::GetPtr(const unsigned thrId) { - if (thrId >= nThreads) + if (thrId >= memory.size()) { - cout << "Memory::GetPtr: " << thrId << " vs. " << nThreads << endl; + cout << "Memory::GetPtr: " << thrId << " vs. " << memory.size() << endl; exit(1); } return memory[thrId]; @@ -117,12 +102,6 @@ double Memory::MemoryInUseMB(const unsigned thrId) const } -void Memory::ReturnAllMemory() -{ - Memory::Resize(0, DDS_TT_SMALL, 0, 0); -} - - string Memory::ThreadSize(const unsigned thrId) const { return threadSizes[thrId]; diff --git a/src/Memory.h b/src/Memory.h index 3f86fa35..90b928dc 100644 --- a/src/Memory.h +++ b/src/Memory.h @@ -117,7 +117,6 @@ class Memory private: vector memory; - unsigned nThreads; vector threadSizes; @@ -127,10 +126,6 @@ class Memory ~Memory(); - void Reset(); - - void ResetThread(const unsigned thrId); - void ReturnThread(const unsigned thrId); void Resize( @@ -139,14 +134,12 @@ class Memory const int memDefault_MB, const int memMaximum_MB); - int NumThreads() const; + unsigned NumThreads() const; ThreadData * GetPtr(const unsigned thrId); double MemoryInUseMB(const unsigned thrId) const; - void ReturnAllMemory(); - string ThreadSize(const unsigned thrId) const; }; diff --git a/src/System.cpp b/src/System.cpp index 3deb5180..52f727b7 100644 --- a/src/System.cpp +++ b/src/System.cpp @@ -274,12 +274,6 @@ bool System::IsIMPL() const } -unsigned System::NumThreads() const -{ - return static_cast(numThreads); -} - - bool System::ThreadOK(const int thrId) const { return (thrId >= 0 && thrId < numThreads); diff --git a/src/System.h b/src/System.h index fd7e8fcc..9f78fea3 100644 --- a/src/System.h +++ b/src/System.h @@ -97,8 +97,6 @@ class System bool IsIMPL() const; - unsigned NumThreads() const; - bool ThreadOK(const int thrId) const; void GetHardware( diff --git a/src/dds.cpp b/src/dds.cpp index fad30225..f6415ec2 100644 --- a/src/dds.cpp +++ b/src/dds.cpp @@ -73,7 +73,6 @@ static void __attribute__ ((constructor)) libInit(void) static void __attribute__ ((destructor)) libEnd(void) { CloseDebugFiles(); - FreeMemory(); } #endif