More example code is memory-leak free now, in particular PhysicsServerExample.
/PhysicsServerCommandProcessor also fixed some memory issue in InverseDynamicsExample (the base class is supposed to delete collision shape memory)
This commit is contained in:
@@ -21,6 +21,7 @@ void GraphingTexture::destroy()
|
||||
m_height=0;
|
||||
glDeleteTextures(1,(GLuint*)&m_textureId);
|
||||
m_textureId=0;
|
||||
|
||||
}
|
||||
|
||||
bool GraphingTexture::create(int texWidth, int texHeight)
|
||||
|
||||
@@ -675,7 +675,10 @@ struct QuickCanvas : public Common2dCanvasInterface
|
||||
virtual void destroyCanvas(int canvasId)
|
||||
{
|
||||
btAssert(canvasId>=0);
|
||||
delete m_gt[canvasId];
|
||||
m_gt[canvasId] = 0;
|
||||
destroyTextureWindow(m_gw[canvasId]);
|
||||
m_gw[canvasId] = 0;
|
||||
m_curNumGraphWindows--;
|
||||
}
|
||||
virtual void setPixel(int canvasId, int x, int y, unsigned char red, unsigned char green,unsigned char blue, unsigned char alpha)
|
||||
@@ -745,6 +748,7 @@ OpenGLExampleBrowser::~OpenGLExampleBrowser()
|
||||
|
||||
delete m_internalData;
|
||||
|
||||
gFileImporterByExtension.clear();
|
||||
gAllExamples = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "../Importers/ImportURDFDemo/ImportURDFSetup.h"
|
||||
#include "../Importers/ImportSDFDemo/ImportSDFSetup.h"
|
||||
#include "../Importers/ImportSTLDemo/ImportSTLSetup.h"
|
||||
|
||||
#include "LinearMath/btAlignedAllocator.h"
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
@@ -49,5 +49,11 @@ int main(int argc, char* argv[])
|
||||
delete exampleBrowser;
|
||||
|
||||
}
|
||||
|
||||
//#ifdef BT_DEBUG_MEMORY_ALLOCATIONS
|
||||
int numBytesLeaked = btDumpMemoryLeaks();
|
||||
btAssert(numBytesLeaked==0);
|
||||
//#endif//BT_DEBUG_MEMORY_ALLOCATIONS
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,6 @@ class InverseDynamicsExample : public CommonMultiBodyBase
|
||||
{
|
||||
btInverseDynamicsExampleOptions m_option;
|
||||
btMultiBody* m_multiBody;
|
||||
btAlignedObjectArray<btCollisionShape*> m_allocatedShapes;
|
||||
btInverseDynamics::MultiBodyTree *m_inverseModel;
|
||||
TimeSeriesCanvas* m_timeSeriesCanvas;
|
||||
public:
|
||||
@@ -107,12 +106,6 @@ InverseDynamicsExample::InverseDynamicsExample(struct GUIHelperInterface* helper
|
||||
InverseDynamicsExample::~InverseDynamicsExample()
|
||||
{
|
||||
|
||||
delete m_multiBody;
|
||||
for (int i = 0; i < m_allocatedShapes.size(); i++)
|
||||
{
|
||||
delete m_allocatedShapes[i];
|
||||
}
|
||||
m_allocatedShapes.resize(0);
|
||||
delete m_inverseModel;
|
||||
delete m_timeSeriesCanvas;
|
||||
}
|
||||
@@ -175,7 +168,7 @@ void InverseDynamicsExample::initPhysics()
|
||||
ConvertURDF2Bullet(u2b,creation, identityTrans,m_dynamicsWorld,true,u2b.getPathPrefix());
|
||||
for (int i = 0; i < u2b.getNumAllocatedCollisionShapes(); i++)
|
||||
{
|
||||
m_allocatedShapes.push_back(u2b.getAllocatedCollisionShape(i));
|
||||
m_collisionShapes.push_back(u2b.getAllocatedCollisionShape(i));
|
||||
}
|
||||
m_multiBody = creation.getBulletMultiBody();
|
||||
if (m_multiBody)
|
||||
|
||||
@@ -31,6 +31,10 @@ struct UrdfLinkNameMapUtil
|
||||
UrdfLinkNameMapUtil():m_mb(0),m_memSerializer(0)
|
||||
{
|
||||
}
|
||||
virtual ~UrdfLinkNameMapUtil()
|
||||
{
|
||||
delete m_memSerializer;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -78,7 +78,6 @@ PhysicsServerSharedMemory::PhysicsServerSharedMemory(SharedMemoryInterface* shar
|
||||
}
|
||||
|
||||
m_data->m_commandProcessor = new PhysicsServerCommandProcessor;
|
||||
m_data->m_commandProcessor ->createEmptyDynamicsWorld();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -701,7 +701,16 @@ void TinyRendererVisualShapeConverter::copyCameraImageData(unsigned char* pixels
|
||||
|
||||
void TinyRendererVisualShapeConverter::resetAll()
|
||||
{
|
||||
//todo: free memory
|
||||
for (int i=0;i<m_data->m_swRenderInstances.size();i++)
|
||||
{
|
||||
TinyRendererObjectArray** ptrptr = m_data->m_swRenderInstances.getAtIndex(i);
|
||||
if (ptrptr && *ptrptr)
|
||||
{
|
||||
TinyRendererObjectArray* ptr = *ptrptr;
|
||||
delete ptr;
|
||||
}
|
||||
}
|
||||
|
||||
m_data->m_swRenderInstances.clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user