'memory usage' bug fix

This commit is contained in:
Joachim Schoeberl 2009-01-28 21:32:30 +00:00
parent 103fe76a1d
commit b087ac2f72
2 changed files with 227 additions and 234 deletions

View File

@ -1,11 +1,5 @@
#include <iostream>
#include <iomanip>
#ifdef SSE
#include <emmintrin.h>
#endif
#include <myadt.hpp>
using namespace std;
namespace netgen
@ -176,7 +170,7 @@ namespace netgen
BaseMoveableMem * pm = BaseMoveableMem::first;
while (pm)
{
long unsigned hptr = (long unsigned) p->ptr;
long unsigned hptr = (long unsigned) pm->ptr;
// uintptr_t hptr = reinterpret_cast<uintptr_t>(pm->ptr);
hptr /= (1024*1024);

View File

@ -12,13 +12,12 @@ namespace netgen
size_t BaseMoveableMem::used = 0;
char * BaseMoveableMem::largeblock = 0;
BaseMoveableMem * BaseMoveableMem::first = 0;
BaseMoveableMem * BaseMoveableMem::last = 0;
BaseMoveableMem * BaseMoveableMem::first = NULL;
BaseMoveableMem * BaseMoveableMem::last = NULL;
BaseMoveableMem :: BaseMoveableMem (size_t s)
{
// cout << "Construct object begin" << endl;
// Print ();
prev = last;
@ -39,10 +38,10 @@ namespace netgen
name = NULL;
if (s) Alloc(s);
}
}
BaseMoveableMem :: ~BaseMoveableMem () throw()
{
BaseMoveableMem :: ~BaseMoveableMem () throw()
{
Free();
if (next) next->prev = prev;
@ -55,10 +54,10 @@ BaseMoveableMem :: ~BaseMoveableMem () throw()
delete [] name;
name = NULL;
}
}
}
void BaseMoveableMem :: SetName (const char * aname)
{
void BaseMoveableMem :: SetName (const char * aname)
{
if(name != NULL)
{
delete [] name;
@ -69,11 +68,11 @@ void BaseMoveableMem :: SetName (const char * aname)
name = new char[strlen(aname)+1];
strcpy (name, aname);
}
}
}
void BaseMoveableMem :: Alloc (size_t s)
{
void BaseMoveableMem :: Alloc (size_t s)
{
if (totalsize == 0)
{
size = s;
@ -134,10 +133,10 @@ void BaseMoveableMem :: Alloc (size_t s)
}
else
ptr = 0;
}
}
void BaseMoveableMem :: ReAlloc (size_t s)
{
void BaseMoveableMem :: ReAlloc (size_t s)
{
if (totalsize == 0)
{
if (size == s) return;
@ -162,10 +161,10 @@ void BaseMoveableMem :: ReAlloc (size_t s)
}
Alloc (s);
}
}
void BaseMoveableMem :: MoveTo (size_t newpos)
{
void BaseMoveableMem :: MoveTo (size_t newpos)
{
// cout << "move block, oldpos = " << pos << "; newpos = " << newpos
// << ", size = " << size << endl;
static size_t move = 0;
@ -188,10 +187,10 @@ void BaseMoveableMem :: MoveTo (size_t newpos)
pos = newpos;
ptr = largeblock+pos;
// cout << "total move: " << move << endl;
}
}
void BaseMoveableMem :: Free () throw()
{
void BaseMoveableMem :: Free () throw()
{
if (totalsize == 0)
{
//free (ptr);
@ -217,10 +216,10 @@ void BaseMoveableMem :: Free () throw()
size = 0;
ptr = 0;
// pos = 0;
}
}
void BaseMoveableMem :: Swap (BaseMoveableMem & m2) throw()
{
void BaseMoveableMem :: Swap (BaseMoveableMem & m2) throw()
{
size_t hi;
// BaseMoveableMem * hp;
char * cp;
@ -232,11 +231,11 @@ void BaseMoveableMem :: Swap (BaseMoveableMem & m2) throw()
*/
cp = ptr; ptr = m2.ptr; m2.ptr = cp;
cp = name; name = m2.name; m2.name = cp;
}
}
void BaseMoveableMem :: Print ()
{
void BaseMoveableMem :: Print ()
{
cout << "****************** Moveable Mem Report ****************" << endl;
BaseMoveableMem * p = first;
long int mem = 0;
@ -266,6 +265,6 @@ void BaseMoveableMem :: Print ()
cout << " used = " << used << endl;
// cout << "******************************************************" << endl;
}
}
}