more guardedalloc use in C++, also make compositorMutex a static var, was allocated and never freed.
This commit is contained in:
parent
cc0784c1b9
commit
3c8a4c458b
@ -1723,6 +1723,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
|
||||
# better not set includes here but this debugging option is off by default.
|
||||
if(WITH_CXX_GUARDEDALLOC)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/intern/guardedalloc)
|
||||
add_definitions(-DWITH_CXX_GUARDEDALLOC)
|
||||
endif()
|
||||
|
||||
if(WITH_ASSERT_ABORT)
|
||||
|
@ -415,14 +415,9 @@ protected:
|
||||
/** The one and only system */
|
||||
static GHOST_ISystem *m_system;
|
||||
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
public:
|
||||
void *operator new(size_t num_bytes) {
|
||||
return MEM_mallocN(num_bytes, "GHOST:GHOST_ISystem");
|
||||
}
|
||||
void operator delete(void *mem) {
|
||||
MEM_freeN(mem);
|
||||
}
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_ISystem")
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -98,6 +98,11 @@ public:
|
||||
private:
|
||||
/** The one and only system paths*/
|
||||
static GHOST_ISystemPaths *m_systemPaths;
|
||||
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_ISystemPaths")
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -84,14 +84,9 @@ public:
|
||||
*/
|
||||
virtual void setUserData(const GHOST_TUserDataPtr userData) = 0;
|
||||
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
public:
|
||||
void *operator new(size_t num_bytes) {
|
||||
return MEM_mallocN(num_bytes, "GHOST:GHOST_ITimerTask");
|
||||
}
|
||||
void operator delete(void *mem) {
|
||||
MEM_freeN(mem);
|
||||
}
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_ITimerTask")
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -37,7 +37,11 @@
|
||||
#include "MEM_guardedalloc.h"
|
||||
#endif
|
||||
|
||||
#define GHOST_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
|
||||
#if defined(WITH_CXX_GUARDEDALLOC) && defined(__cplusplus)
|
||||
# define GHOST_DECLARE_HANDLE(name) typedef struct name##__ { int unused; MEM_CXX_CLASS_ALLOC_FUNCS(#name) } *name
|
||||
#else
|
||||
# define GHOST_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
|
||||
#endif
|
||||
|
||||
typedef char GHOST_TInt8;
|
||||
typedef unsigned char GHOST_TUns8;
|
||||
|
@ -73,6 +73,10 @@ protected:
|
||||
GHOST_EventCallbackProcPtr m_eventCallback;
|
||||
/** The data passed back though the call-back routine. */
|
||||
GHOST_TUserDataPtr m_userData;
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_CallbackEventConsumer")
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // __GHOST_CALLBACKEVENTCONSUMER_H__
|
||||
|
@ -133,6 +133,11 @@ protected:
|
||||
bool m_settingsInitialized;
|
||||
/** The list with display settings for the main display. */
|
||||
std::vector<GHOST_DisplaySettings> m_settings;
|
||||
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_DisplayManager")
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
@ -168,6 +168,11 @@ protected:
|
||||
|
||||
/** The list with event consumers. */
|
||||
TConsumerVector m_consumers;
|
||||
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_EventManager")
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // __GHOST_EVENTMANAGER_H__
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
*/
|
||||
virtual const GHOST_TUns8 *getSystemDir(int version, const char *versionstr) const = 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Determine the base dir in which user configuration is stored, including versioning.
|
||||
* If needed, it will create the base directory.
|
||||
* @return Unsigned char string pointing to user dir (eg ~/.blender/).
|
||||
@ -74,7 +74,6 @@ public:
|
||||
* Add the file to the operating system most recently used files
|
||||
*/
|
||||
virtual void addToSystemRecentFiles(const char *filename) const = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -119,6 +119,11 @@ protected:
|
||||
typedef std::vector<GHOST_TimerTask *> TTimerVector;
|
||||
/** The list with event consumers. */
|
||||
TTimerVector m_timers;
|
||||
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_TimerManager")
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // __GHOST_TIMERMANAGER_H__
|
||||
|
@ -28,20 +28,36 @@
|
||||
#include <new>
|
||||
#include "../MEM_guardedalloc.h"
|
||||
|
||||
void* operator new (size_t size)
|
||||
{
|
||||
return MEM_mallocN(size, "C++/anonymous");
|
||||
}
|
||||
|
||||
/* not default but can be used when needing to set a string */
|
||||
void* operator new (size_t size, const char *str)
|
||||
void *operator new(size_t size, const char *str)
|
||||
{
|
||||
return MEM_mallocN(size, str);
|
||||
}
|
||||
void *operator new[](size_t size, const char *str)
|
||||
{
|
||||
return MEM_mallocN(size, str);
|
||||
}
|
||||
|
||||
void operator delete (void *p)
|
||||
|
||||
void *operator new(size_t size)
|
||||
{
|
||||
return MEM_mallocN(size, "C++/anonymous");
|
||||
}
|
||||
void *operator new[](size_t size)
|
||||
{
|
||||
return MEM_mallocN(size, "C++/anonymous[]");
|
||||
}
|
||||
|
||||
|
||||
void operator delete(void *p)
|
||||
{
|
||||
/* delete NULL is valid in c++ */
|
||||
if(p)
|
||||
if (p)
|
||||
MEM_freeN(p);
|
||||
}
|
||||
void operator delete[](void *p)
|
||||
{
|
||||
/* delete NULL is valid in c++ */
|
||||
if (p)
|
||||
MEM_freeN(p);
|
||||
}
|
||||
|
@ -23,6 +23,10 @@
|
||||
#ifndef _COM_ChunkOrderHotSpot_h_
|
||||
#define _COM_ChunkOrderHotSpot_h_
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
#include "MEM_guardedalloc.h"
|
||||
#endif
|
||||
|
||||
class ChunkOrderHotspot {
|
||||
private:
|
||||
int x;
|
||||
@ -32,6 +36,11 @@ private:
|
||||
public:
|
||||
ChunkOrderHotspot(int x, int y, float addition);
|
||||
double determineDistance(int x, int y);
|
||||
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("COM:ChunkOrderHotspot")
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -41,6 +41,10 @@
|
||||
|
||||
#include "BKE_global.h"
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
#include "MEM_guardedalloc.h"
|
||||
#endif
|
||||
|
||||
ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering)
|
||||
{
|
||||
context.setbNodeTree(editingtree);
|
||||
|
@ -270,6 +270,10 @@ protected:
|
||||
* @brief set if this NodeOperation can be scheduled on a OpenCLDevice
|
||||
*/
|
||||
void setOpenCL(bool openCL) { this->openCL = openCL; }
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -29,6 +29,10 @@
|
||||
#include "DNA_node_types.h"
|
||||
#include "COM_defines.h"
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
#include "MEM_guardedalloc.h"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
class SocketConnection;
|
||||
class NodeBase;
|
||||
|
@ -25,6 +25,10 @@
|
||||
#include "BLI_rect.h"
|
||||
#include "COM_defines.h"
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
#include "MEM_guardedalloc.h"
|
||||
#endif
|
||||
|
||||
typedef enum PixelSampler {
|
||||
COM_PS_NEAREST,
|
||||
COM_PS_BILINEAR,
|
||||
|
@ -33,20 +33,21 @@ extern "C" {
|
||||
#include "COM_WorkScheduler.h"
|
||||
#include "OCL_opencl.h"
|
||||
|
||||
static ThreadMutex *compositorMutex;
|
||||
static ThreadMutex compositorMutex = {{0}};
|
||||
static char is_compositorMutex_init = FALSE;
|
||||
void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering)
|
||||
{
|
||||
if (compositorMutex == NULL) { /// TODO: move to blender startup phase
|
||||
compositorMutex = new ThreadMutex();
|
||||
BLI_mutex_init(compositorMutex);
|
||||
if (is_compositorMutex_init == FALSE) { /// TODO: move to blender startup phase
|
||||
BLI_mutex_init(&compositorMutex);
|
||||
OCL_init();
|
||||
WorkScheduler::initialize(); ///TODO: call workscheduler.deinitialize somewhere
|
||||
is_compositorMutex_init = TRUE;
|
||||
}
|
||||
BLI_mutex_lock(compositorMutex);
|
||||
BLI_mutex_lock(&compositorMutex);
|
||||
if (editingtree->test_break(editingtree->tbh)) {
|
||||
// during editing multiple calls to this method can be triggered.
|
||||
// make sure one the last one will be doing the work.
|
||||
BLI_mutex_unlock(compositorMutex);
|
||||
BLI_mutex_unlock(&compositorMutex);
|
||||
return;
|
||||
|
||||
}
|
||||
@ -60,5 +61,5 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering)
|
||||
system->execute();
|
||||
delete system;
|
||||
|
||||
BLI_mutex_unlock(compositorMutex);
|
||||
BLI_mutex_unlock(&compositorMutex);
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ public: \
|
||||
void *operator new(size_t num_bytes) { \
|
||||
return MEM_mallocN(num_bytes, Type.tp_name); \
|
||||
} \
|
||||
void operator delete( void *mem ) { \
|
||||
void operator delete(void *mem) { \
|
||||
MEM_freeN(mem); \
|
||||
} \
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user