Hello,
it seems the VehicleDemo has a memory leak, just looked older revisions - looks like last revision without was 2.69. BTW, i use newest vehicle classes without problems in my app.
Vehicle Demo leaks memory?
-
- Posts: 144
- Joined: Fri Aug 01, 2008 6:36 am
- Location: Bonn, Germany
Vehicle Demo leaks memory?
Last edited by mi076 on Wed Sep 24, 2008 6:57 pm, edited 1 time in total.
-
- Posts: 144
- Joined: Fri Aug 01, 2008 6:36 am
- Location: Bonn, Germany
Re: Vehicle Demo leaks memory?
... it is
btCylinderShapeX wheelShape(btVector3(wheelWidth,wheelRadius,wheelRadius));
in void VehicleDemo::renderme() function.
btCylinderShapeX wheelShape(btVector3(wheelWidth,wheelRadius,wheelRadius));
in void VehicleDemo::renderme() function.
-
- Posts: 144
- Joined: Fri Aug 01, 2008 6:36 am
- Location: Bonn, Germany
Re: Vehicle Demo and ForkLift has memory leak
The problem was imported into ForkLiftDemo (great demo btw).
Just look at "alloc-free" or any memory monitor.
May be there is some work in progress, if so ignore the message.
Just look at "alloc-free" or any memory monitor.
May be there is some work in progress, if so ignore the message.
-
- Posts: 4
- Joined: Wed Mar 19, 2008 7:15 pm
Re: Vehicle Demo leaks memory?
mi076 wrote:... it is
btCylinderShapeX wheelShape(btVector3(wheelWidth,wheelRadius,wheelRadius));
in void VehicleDemo::renderme() function.
Code: Select all
void VehicleDemo::renderme()
{
updateCamera();
btScalar m[16];
int i;
static btCylinderShapeX *wheelShape=new btCylinderShapeX(btVector3(wheelWidth,wheelRadius,wheelRadius));
btVector3 wheelColor(1,0,0);
btVector3 worldBoundsMin,worldBoundsMax;
getDynamicsWorld()->getBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax);
for (i=0;i<m_vehicle->getNumWheels();i++)
{
//synchronize the wheels with the (interpolated) chassis worldtransform
m_vehicle->updateWheelTransform(i,true);
//draw wheels (cylinders)
m_vehicle->getWheelInfo(i).m_worldTransform.getOpenGLMatrix(m);
m_shapeDrawer.drawOpenGL(m,wheelShape,wheelColor,getDebugMode(),worldBoundsMin,worldBoundsMax);
}
DemoApplication::renderme();
}
-
- Posts: 1
- Joined: Sun May 10, 2009 4:44 am
Re: Vehicle Demo leaks memory?
I still got memory leak in Forklift demo in Bullet 2.7.4.
GL_ShapeDrawer seems to cause the problem when drawing wheels as it create a new glTexture every time. The memory will not leak if the texture rendering is disabled.
GL_ShapeDrawer seems to cause the problem when drawing wheels as it create a new glTexture every time. The memory will not leak if the texture rendering is disabled.
-
- Posts: 144
- Joined: Fri Aug 01, 2008 6:36 am
- Location: Bonn, Germany
Re: Vehicle Demo leaks memory?
Probably the problem is not the texture itself.. I have checked it, texture creation stuff is called once.... But there is a line in GL_ShapeDrawer::drawOpenGLGL_ShapeDrawer seems to cause the problem when drawing wheels as it create a new glTexture every time. The memory will not leak if the texture rendering is disabled.
Code: Select all
int shapetype=m_textureenabled?MAX_BROADPHASE_COLLISION_TYPES:shape->getShapeType();
Code: Select all
switch (shapetype)
{
...
default:
{
if (shape->isConvex())
{
ShapeCache * sc=cache((btConvexShape*)shape);
...
shapetype=m_textureenabled?MAX_BROADPHASE_COLLISION_TYPES:shape->getShapeType();
to
int shapetype=shape->getShapeType();
the shape will be drawn as CYLINDER_SHAPE_PROXYTYPE without using of ShapeCache and there is no leak..
I didn't look deeper (how the Cache works and is it a bug) ... most likely cylinder shapes created on stack every frame are all going into cache.
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Vehicle Demo leaks memory?
We'll check it out, but where are you deleting the wheelshape, allocated in
Thanks,
Erwin
Code: Select all
static btCylinderShapeX *wheelShape=new btCylinderShapeX(btVector3(wheelWidth,wheelRadius,wheelRadius));
Erwin
-
- Posts: 144
- Joined: Fri Aug 01, 2008 6:36 am
- Location: Bonn, Germany
Re: Vehicle Demo leaks memory?
... have defined m_wheelShape in VehicleDemo and ForkLiftDemo classes, patch in attachment.
Thanks.
Thanks.
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Vehicle Demo leaks memory?
The patch has been applied:
http://code.google.com/p/bullet/source/detail?r=1662
Thanks for the report+fix!
Erwin
http://code.google.com/p/bullet/source/detail?r=1662
Thanks for the report+fix!
Erwin