Elbeem: fix memory leak and add guarded allocator directives

This commit is contained in:
Sergey Sharybin 2013-09-27 18:55:26 +00:00
parent 16da43ef19
commit dad37860e2
25 changed files with 285 additions and 3 deletions

@ -25,6 +25,7 @@
set(INC
extern
../guardedalloc
)
set(INC_SYS

@ -43,6 +43,6 @@ if env['WITH_BF_OPENMP']:
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
defs += ' USE_MSVC6FIXES'
incs += ' ' + env['BF_PNG_INC'] + ' ' + env['BF_ZLIB_INC']
incs += ' extern '
incs += ' extern ../../guardedalloc'
env.BlenderLib ('bf_intern_elbeem', sources, Split(incs), Split(defs), libtype='intern', priority=0 )

@ -14,6 +14,11 @@
#ifndef NTL_ATTRIBUTES_H
#include "utilities.h"
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
template<class T> class ntlMatrix4x4;
class ntlSetVec3f;
std::ostream& operator<<( std::ostream& os, const ntlSetVec3f& i );
@ -110,6 +115,11 @@ class AnimChannel
vector<Scalar> mValue;
/*! anim channel attr times */
vector<double> mTimes;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:AnimChannel")
#endif
};
@ -127,6 +137,11 @@ class ntlSetVec3f {
ntlSetVec3f& operator*=( const ntlSetVec3f &v );
vector<ntlVec3f> mVerts;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlSetVec3f")
#endif
};
@ -163,6 +178,11 @@ class Attribute
protected:
bool initChannel(int elemSize);
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:Attribute")
#endif
};
@ -195,6 +215,11 @@ class AttributeList
bool ignoreParameter(string name, string source);
void print();
protected:
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:AttributeList")
#endif
};
ntlVec3f channelFindMaxVf (AnimChannel<ntlVec3f> channel);

@ -18,6 +18,10 @@
#include "ntl_geometrymodel.h"
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
// indicator for LBM inclusion
//#ifndef LBMDIM
@ -80,6 +84,11 @@ public:
forceAtt = forceVel = forceMaxd = LbmVec(0.,0.,0.);
compAvWeight=0.; compAv=LbmVec(0.);
};
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ControlForces")
#endif
};
@ -115,6 +124,11 @@ public:
// init all zero / defaults
void reset();
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ControlParticle")
#endif
};
@ -128,6 +142,10 @@ public:
// particle positions
std::vector<ControlParticle> particles;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ControlParticleSet")
#endif
};
@ -296,6 +314,11 @@ protected:
void initTimeArray(LbmFloat t, std::vector<ControlParticle> &parts);
bool checkPointInside(ntlTree *tree, ntlVec3Gfx org, gfxReal &distance);
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ControlParticles")
#endif
};

@ -15,6 +15,10 @@
#include "ntl_geometryobject.h"
#include "ntl_bsptree.h"
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
#define ISO_STRICT_DEBUG 0
#define ISOSTRICT_EXIT *((int *)0)=0;
@ -224,6 +228,11 @@ class IsoSurface :
vector<int> mDboundary;
float mSCrad1, mSCrad2;
ntlVec3Gfx mSCcenter;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:IsoSurface")
#endif
};

@ -34,6 +34,10 @@
#include "ieeefp.h"
#endif
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
// weight and triangle index
class mvmIndexWeight {
public:
@ -49,6 +53,11 @@ class mvmIndexWeight {
mvmFloat weight;
int index;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:mvmIndexWeight")
#endif
};
// transfer point with weights
@ -58,6 +67,11 @@ class mvmTransferPoint {
ntlVec3Gfx lastpos;
//! triangle weights
std::vector<mvmIndexWeight> weights;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:mvmTransferPoint")
#endif
};
@ -86,6 +100,10 @@ class MeanValueMeshCoords {
std::vector<mvmTransferPoint> mVertices;
int mNumVerts;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:MeanValueMeshCoords")
#endif
};
#endif

@ -12,6 +12,10 @@
#ifndef NTL_BLENDERDUMPER_H
#include "ntl_world.h"
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
class ntlBlenderDumper :
public ntlWorld
{
@ -27,6 +31,10 @@ public:
protected:
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlBlenderDumper")
#endif
};
#define NTL_BLENDERDUMPER_H

@ -22,6 +22,9 @@
#define BSP_STACK_SIZE 50
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
//! bsp tree stack classes, defined in ntl_bsptree.cpp,
// detailed definition unnecesseary here
@ -120,6 +123,10 @@ class ntlTree
//! duplicated triangles, inited during subdivide
int mTriDoubles;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlTree")
#endif
};

@ -16,6 +16,10 @@
#include "attributes.h"
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
//! geometry class type ids
#define GEOCLASSTID_OBJECT 1
#define GEOCLASSTID_SHADER 2
@ -111,6 +115,10 @@ class ntlGeometryClass
private:
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlGeometryClass")
#endif
};

@ -14,6 +14,10 @@
#include "ntl_geometryobject.h"
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
/*! A simple box object generatedd by 12 triangles */
class ntlGeometryObjModel : public ntlGeometryObject
{
@ -89,6 +93,11 @@ class ntlGeometryObjModel : public ntlGeometryObject
/*! set data file name */
inline void setFilename(string set) { mFilename = set; }
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlGeometryObjModel")
#endif
};
#endif

@ -16,6 +16,11 @@
#include "ntl_geometryclass.h"
#include "ntl_lighting.h"
#include "ntl_ray.h"
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
class ntlRenderGlobals;
class ntlTriangle;
@ -240,6 +245,10 @@ class ntlGeometryObject : public ntlGeometryClass
public:
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlGeometryObject")
#endif
};
#endif

@ -13,6 +13,11 @@
#define NTL_GEOMETRYSHADER_H
#include "ntl_geometryclass.h"
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
class ntlGeometryObject;
class ntlRenderGlobals;
@ -57,6 +62,11 @@ class ntlGeometryShader :
/*! surface output name for this simulation */
string mOutFilename;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlGeometryShader")
#endif
};
#endif

@ -14,6 +14,11 @@
#define NTL_LIGHTING_H
#include "ntl_vector3dim.h"
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
class ntlMaterial;
class ntlRay;
class ntlRenderGlobals;
@ -88,6 +93,10 @@ protected:
private:
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlLightObject")
#endif
};
@ -195,6 +204,10 @@ public:
//! Set Fresnel on/off
inline void setFresnel(int set) { mFresnel = set; }
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlMaterial")
#endif
};

@ -14,6 +14,9 @@
#include "ntl_vector3dim.h"
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
// The basic vector class
template<class Scalar>
@ -96,6 +99,10 @@ public:
protected:
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlMatrix4x4")
#endif
};

@ -18,6 +18,10 @@
#include "ntl_geometryobject.h"
#include "ntl_bsptree.h"
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
class ntlTriangle;
class ntlRay;
class ntlTree;
@ -39,6 +43,11 @@ class ntlIntersection {
ntlRay *ray;
ntlTriangle *tri;
char flags;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlIntersection")
#endif
};
//! the main ray class
@ -138,6 +147,10 @@ private:
/*! ID of this ray (from renderglobals */
int mID;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlRay")
#endif
};
@ -225,6 +238,10 @@ private:
/*! ID of last ray that an intersection was calculated for */
int mLastRay;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlTriangle")
#endif
};
@ -410,6 +427,10 @@ private:
/*! shader/obj initializations are only done on first init */
bool mFirstInitDone;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlScene")
#endif
};

@ -32,6 +32,10 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
/* absolute value */
template < class T >
inline T
@ -205,6 +209,11 @@ protected:
private:
Scalar value[3]; //< Storage of vector values
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlVector3Dim")
#endif
};

@ -18,6 +18,11 @@
#include "ntl_geometryobject.h"
#include "simulation_object.h"
#include "elbeem.h"
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
class ntlOpenGLRenderer;
class ntlScene;
class SimulationObject;
@ -119,6 +124,11 @@ class ntlWorld
/*! count no. of frame for correct sim time */
int mSimFrameCnt;
vector<int> mSimFrameValue;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlWorld")
#endif
};
@ -389,6 +399,11 @@ private:
bool mSingleFrameMode;
//! filename for single frame mode
string mSingleFrameFilename;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlRenderGlobals")
#endif
};

@ -17,6 +17,10 @@
#include "utilities.h"
#include "attributes.h"
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
/* parametrizer accuracy */
typedef double ParamFloat;
typedef ntlVec3d ParamVec;
@ -306,6 +310,11 @@ class Parametrizer {
/*! pointer to the attribute list */
AttributeList *mpAttrs;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:Parametrizer")
#endif
};

@ -53,6 +53,7 @@ ParticleTracer::ParticleTracer() :
ParticleTracer::~ParticleTracer() {
debMsgStd("ParticleTracer::~ParticleTracer",DM_MSG,"destroyed",10);
if(mpTrafo) delete mpTrafo;
}
/*****************************************************************************/

@ -12,6 +12,11 @@
#ifndef NTL_PARTICLETRACER_H
#include "ntl_geometryobject.h"
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
template<class Scalar> class ntlMatrix4x4;
// particle types
@ -131,6 +136,11 @@ class ParticleObject
/* for list constructions */
ParticleObject *mpNext;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ParticleObject")
#endif
};
@ -274,6 +284,11 @@ class ParticleTracer :
/* prev pos save interval */
float mTrailTimeLast, mTrailInterval;
int mTrailLength;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ParticleTracer")
#endif
};
#define NTL_PARTICLETRACER_H

@ -18,6 +18,10 @@
#include "ntl_geometryshader.h"
#include "parametrizer.h"
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
class LbmSolverInterface;
class CellIdentifierInterface;
class ntlTree;
@ -188,6 +192,11 @@ class SimulationObject :
virtual inline ntlVec3Gfx *getBBStart() { return &mGeoStart; }
virtual inline ntlVec3Gfx *getBBEnd() { return &mGeoEnd; }
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:SimulationObject")
#endif
};

@ -21,6 +21,10 @@
#include "ntl_ray.h"
#include <stdio.h>
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
#if PARALLEL==1
#include <omp.h>
#endif // PARALLEL=1
@ -145,6 +149,11 @@ class UniformFsgrCellIdentifier :
if( x==cid->x && y==cid->y && z==cid->z && level==cid->level ) return true;
return false;
}
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:UniformFsgrCellIdentifier")
#endif
};
//! information needed for each level in the simulation
@ -193,6 +202,10 @@ public:
int lSizex, lSizey, lSizez;
int lOffsx, lOffsy, lOffsz;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:FsgrLevelData")
#endif
};
@ -740,6 +753,11 @@ class LbmFsgrSolver :
static LbmFloat lesCoeffOffdiag[ 2 ][ 9 ];
# endif // LBMDIM==2
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:LbmFsgrSolver")
#endif
};
#undef STCON

@ -225,7 +225,10 @@ LbmFsgrSolver::initCpdata()
// manually switch on! if this is zero, nothing is done...
mpControl->mSetForceStrength = this->mTForceStrength = 1.;
mpControl->mCons.clear();
while (!mpControl->mCons.empty()) {
delete mpControl->mCons.back(); mpControl->mCons.pop_back();
}
// init all control fluid objects
int numobjs = (int)(mpGiObjects->size());
@ -264,7 +267,9 @@ LbmFsgrSolver::initCpdata()
if(0) {
// manually switch on! if this is zero, nothing is done...
mpControl->mSetForceStrength = this->mTForceStrength = 1.;
mpControl->mCons.clear();
while (!mpControl->mCons.empty()) {
delete mpControl->mCons.back(); mpControl->mCons.pop_back();
}
// add new set
LbmControlSet *cset;

@ -16,6 +16,10 @@
#ifndef LBM_TESTCLASS_H
#define LBM_TESTCLASS_H
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
//class IsoSurface;
class ParticleObject;
class ControlParticles;
@ -147,6 +151,11 @@ class LbmControlSet {
AnimChannel<ntlVec3f> mcCpScale;
AnimChannel<ntlVec3f> mcCpOffset;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:LbmControlSet")
#endif
};
@ -180,6 +189,11 @@ class LbmControlData
// cp debug displau
LbmFloat mDebugCpscale, mDebugVelScale, mDebugCompavScale, mDebugAttScale, mDebugMaxdScale, mDebugAvgVelScale;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:LbmControlData ")
#endif
};
#endif // LBM_TESTCLASS_H

@ -35,6 +35,11 @@
#include "parametrizer.h"
#include "attributes.h"
#include "isosurface.h"
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
class ParticleTracer;
class ParticleObject;
@ -171,6 +176,11 @@ class LbmCellContents {
CellFlagType flag;
BubbleId bubble;
LbmFloat ffrac;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:LbmCellContents")
#endif
};
/* struct for the coordinates of a cell in the grid */
@ -224,6 +234,10 @@ class CellIdentifierInterface {
//! has the grid been traversed?
bool mEnd;
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:CellIdentifierInterface")
#endif
};
@ -601,6 +615,11 @@ class LbmSolverInterface
#if PARALLEL==1
int mNumOMPThreads;
#endif // PARALLEL==1
private:
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:LbmSolverInterface")
#endif
};