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