mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
initial commit
This change makes the memory manager work again for detecting leaks, the built in one kept coming into de-ref and other bugs so this is the start of a refactor to get it working.
This commit is contained in:
parent
13bf126418
commit
8c812cb448
|
|
@ -114,29 +114,6 @@ namespace engineAPI
|
|||
}
|
||||
|
||||
|
||||
|
||||
// The following are some tricks to make the memory leak checker run after global
|
||||
// dtors have executed by placing some code in the termination segments.
|
||||
|
||||
#if defined( TORQUE_DEBUG ) && !defined( TORQUE_DISABLE_MEMORY_MANAGER )
|
||||
|
||||
#ifdef TORQUE_COMPILER_VISUALC
|
||||
# pragma data_seg( ".CRT$XTU" )
|
||||
|
||||
static void* sCheckMemBeforeTermination = &Memory::ensureAllFreed;
|
||||
|
||||
# pragma data_seg()
|
||||
#elif defined( TORQUE_COMPILER_GCC )
|
||||
|
||||
__attribute__ ( ( destructor ) ) static void _ensureAllFreed()
|
||||
{
|
||||
Memory::ensureAllFreed();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// Process a time event and update all sub-processes
|
||||
void processTimeEvent(S32 elapsedTime)
|
||||
{
|
||||
|
|
@ -216,10 +193,6 @@ void StandardMainLoop::init()
|
|||
gStartupTimer = PlatformTimer::create();
|
||||
#endif
|
||||
|
||||
#ifdef TORQUE_DEBUG_GUARD
|
||||
Memory::flagCurrentAllocs( Memory::FLAG_Global );
|
||||
#endif
|
||||
|
||||
Platform::setMathControlStateKnown();
|
||||
|
||||
// Asserts should be created FIRST
|
||||
|
|
@ -327,10 +300,6 @@ void StandardMainLoop::init()
|
|||
|
||||
// Hook in for UDP notification
|
||||
Net::getPacketReceiveEvent().notify(GNet, &NetInterface::processPacketReceiveEvent);
|
||||
|
||||
#ifdef TORQUE_DEBUG_GUARD
|
||||
Memory::flagCurrentAllocs( Memory::FLAG_Static );
|
||||
#endif
|
||||
}
|
||||
|
||||
void StandardMainLoop::shutdown()
|
||||
|
|
@ -378,9 +347,6 @@ void StandardMainLoop::shutdown()
|
|||
// asserts should be destroyed LAST
|
||||
PlatformAssert::destroy();
|
||||
|
||||
#if defined( TORQUE_DEBUG ) && !defined( TORQUE_DISABLE_MEMORY_MANAGER )
|
||||
Memory::validate();
|
||||
#endif
|
||||
}
|
||||
|
||||
void StandardMainLoop::preShutdown()
|
||||
|
|
|
|||
|
|
@ -205,6 +205,7 @@ int main(int argc, const char **argv)
|
|||
#include "platform/platform.h"
|
||||
#include "app/mainLoop.h"
|
||||
#include "T3D/gameFunctions.h"
|
||||
#include "platform/platformMemory.h"
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
//tell switchable graphics supported systems that they need to use the beefier GPU
|
||||
|
|
@ -230,8 +231,9 @@ S32 TorqueMain(S32 argc, const char **argv)
|
|||
// argv = argvFake;
|
||||
// }
|
||||
|
||||
// Memory::enableLogging("testMem.log");
|
||||
// Memory::setBreakAlloc(104717);
|
||||
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
||||
Memory::init();
|
||||
#endif
|
||||
|
||||
// Initialize the subsystems.
|
||||
StandardMainLoop::init();
|
||||
|
|
@ -254,6 +256,11 @@ S32 TorqueMain(S32 argc, const char **argv)
|
|||
if( StandardMainLoop::requiresRestart() )
|
||||
Platform::restartInstance();
|
||||
|
||||
|
||||
#if defined( TORQUE_DEBUG ) && !defined( TORQUE_DISABLE_MEMORY_MANAGER )
|
||||
Memory::shutdown();
|
||||
#endif
|
||||
|
||||
// Return.
|
||||
return StandardMainLoop::getReturnStatus();
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -27,33 +27,22 @@
|
|||
|
||||
namespace Memory
|
||||
{
|
||||
enum EFlag
|
||||
struct MemInfo
|
||||
{
|
||||
FLAG_Debug,
|
||||
FLAG_Global,
|
||||
FLAG_Static
|
||||
void* ptr;
|
||||
dsize_t size;
|
||||
const char* file;
|
||||
U32 line;
|
||||
U32 allocId;
|
||||
bool flagged;
|
||||
|
||||
void* backtracePtrs[16];
|
||||
int backtraceSize;
|
||||
};
|
||||
|
||||
struct Info
|
||||
{
|
||||
U32 mAllocNumber;
|
||||
U32 mAllocSize;
|
||||
const char* mFileName;
|
||||
U32 mLineNumber;
|
||||
bool mIsArray;
|
||||
bool mIsGlobal;
|
||||
bool mIsStatic;
|
||||
};
|
||||
|
||||
void checkPtr( void* ptr );
|
||||
void flagCurrentAllocs( EFlag flag = FLAG_Debug );
|
||||
void ensureAllFreed();
|
||||
void dumpUnflaggedAllocs(const char *file, EFlag flag = FLAG_Debug );
|
||||
S32 countUnflaggedAllocs(const char *file, S32 *outUnflaggedRealloc = NULL, EFlag flag = FLAG_Debug );
|
||||
dsize_t getMemoryUsed();
|
||||
dsize_t getMemoryAllocated();
|
||||
void getMemoryInfo( void* ptr, Info& info );
|
||||
void validate();
|
||||
void init();
|
||||
void shutdown();
|
||||
void checkPtr(void* ptr);
|
||||
}
|
||||
|
||||
#endif // _TORQUE_PLATFORM_PLATFORMMEMORY_H_
|
||||
|
|
|
|||
|
|
@ -29,12 +29,23 @@
|
|||
#include "ts/tsMaterialList.h"
|
||||
#include "core/stream/fileStream.h"
|
||||
|
||||
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
||||
#ifdef new
|
||||
#undef new
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// assimp include files.
|
||||
#include <assimp/cimport.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/postprocess.h>
|
||||
#include <assimp/types.h>
|
||||
|
||||
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
||||
# define _new new(__FILE__, __LINE__)
|
||||
# define new _new
|
||||
#endif
|
||||
|
||||
U32 AssimpAppMaterial::sDefaultMatNumber = 0;
|
||||
|
||||
String AppMaterial::cleanString(const String& str)
|
||||
|
|
|
|||
|
|
@ -26,8 +26,20 @@
|
|||
#ifndef _APPMATERIAL_H_
|
||||
#include "ts/loader/appMaterial.h"
|
||||
#endif
|
||||
|
||||
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
||||
#ifdef new
|
||||
#undef new
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <assimp/scene.h>
|
||||
|
||||
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
||||
# define _new new(__FILE__, __LINE__)
|
||||
# define new _new
|
||||
#endif
|
||||
|
||||
class Material;
|
||||
|
||||
class AssimpAppMaterial : public AppMaterial
|
||||
|
|
|
|||
|
|
@ -24,12 +24,24 @@
|
|||
#include "ts/collada/colladaExtensions.h"
|
||||
#include "ts/assimp/assimpAppMesh.h"
|
||||
|
||||
|
||||
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
||||
#ifdef new
|
||||
#undef new
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// assimp include files.
|
||||
#include <assimp/cimport.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/postprocess.h>
|
||||
#include <assimp/types.h>
|
||||
|
||||
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
||||
# define _new new(__FILE__, __LINE__)
|
||||
# define new _new
|
||||
#endif
|
||||
|
||||
bool AssimpAppMesh::fixedSizeEnabled = false;
|
||||
S32 AssimpAppMesh::fixedSize = 2;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,12 +25,25 @@
|
|||
#include "ts/assimp/assimpAppNode.h"
|
||||
#include "ts/assimp/assimpAppMesh.h"
|
||||
|
||||
|
||||
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
||||
#ifdef new
|
||||
#undef new
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// assimp include files.
|
||||
#include <assimp/cimport.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/postprocess.h>
|
||||
#include <assimp/types.h>
|
||||
|
||||
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
||||
# define _new new(__FILE__, __LINE__)
|
||||
# define new _new
|
||||
#endif
|
||||
|
||||
|
||||
aiAnimation* AssimpAppNode::sActiveSequence = NULL;
|
||||
F32 AssimpAppNode::sTimeMultiplier = 1.0f;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,11 +33,23 @@
|
|||
#include "ts/collada/colladaExtensions.h"
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
||||
#ifdef new
|
||||
#undef new
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef AI_TYPES_H_INC
|
||||
#include <assimp/types.h>
|
||||
#endif
|
||||
#include <assimp/scene.h>
|
||||
|
||||
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
||||
# define _new new(__FILE__, __LINE__)
|
||||
# define new _new
|
||||
#endif
|
||||
|
||||
class AssimpAppMesh;
|
||||
|
||||
class AssimpAppNode : public AppNode
|
||||
|
|
|
|||
|
|
@ -18,8 +18,20 @@
|
|||
#include "ts/loader/appSequence.h"
|
||||
#endif
|
||||
|
||||
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
||||
#ifdef new
|
||||
#undef new
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <assimp/scene.h>
|
||||
|
||||
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
||||
# define _new new(__FILE__, __LINE__)
|
||||
# define new _new
|
||||
#endif
|
||||
|
||||
|
||||
class AssimpAppSequence : public AppSequence
|
||||
{
|
||||
String mSequenceName;
|
||||
|
|
|
|||
|
|
@ -51,6 +51,11 @@
|
|||
#include "gfx/bitmap/gBitmap.h"
|
||||
#include "gui/controls/guiTreeViewCtrl.h"
|
||||
|
||||
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
||||
#ifdef new
|
||||
#undef new
|
||||
#endif
|
||||
#endif
|
||||
// assimp include files.
|
||||
#include <assimp/cimport.h>
|
||||
#include <assimp/scene.h>
|
||||
|
|
@ -59,6 +64,12 @@
|
|||
#include <assimp/config.h>
|
||||
#include <exception>
|
||||
|
||||
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
||||
# define _new new(__FILE__, __LINE__)
|
||||
# define new _new
|
||||
#endif
|
||||
|
||||
|
||||
MODULE_BEGIN( AssimpShapeLoader )
|
||||
MODULE_INIT_AFTER( ShapeLoader )
|
||||
MODULE_INIT
|
||||
|
|
|
|||
Loading…
Reference in a new issue