Box2d slowing down

Hi, I've written a VERY simple demo program using box2d and glut. It's around 1000 lines of code, and isnt really very special or processor intensive.

However, I have noticed, that as it runs, it gradually slows down, and I have no idea why. At the start it is extremely quick, however, after about a minute everything is running extremely sluggishly.

I'm wondering if anybody else has encountered something like this before, as it has confused me no end. I've never really attempted any optimisation of my code (c++) however I doubt that that is the problem, as it seems to run slower over time, instead of at the beginning.

Help? please?

(btw, if you want source code to help explain the problem, just ask)
Are you sure you aren't leaking something. OpenGL resources are very easy to leak. Make sure you destroy bodies you aren't using too, even if they have no shapes.

If you destroy the Box2D world this is guaranteed to clean up up everything in the world. You might want to delete and re-create it to see if it is the source of your problem or not.
I think you may be right, it may be something to do with memory leakage, or not disposing of unused bodies, however I don't think it is opengl's fault as I have build other programs with opengl which haven't slowed down at all. I will take your advice and try destroying and recreating the world, and seeing if that does anything...

[edit]

I tried recreating the world, and it did help with the performance issues, however this is extremely annoying if I wanted it use it in a game. However it does suggest that it is something that box2d (or me) is doing that is causing the slowdown. I'm going to go back through my code and see if their are any instances where I am not destroying stuff properly...
Right, I've tracked down the problem, I was creating a body for the ray casts that I was doing, and not deleting it afterwards, so every time I did a ray cast (every frame) I was creating an extra body. thanks for your advice, and I know not to do this again!
Box2D tracks the number of bytes allocated with a counter in b2Settings.
Ohh, that's useful! To be honest it was my own stupidity which caused the problem this time, however it may be useful to put some sort of warning in the raycast example in the testbed for those wanting to re-use the code, that the body needs to be destroyed when the raycast is. I realize that this is not a problem in the testbed as the body is persistant throughout, and is destroyed with the world.

Original thread: https://box2d.org/forum/viewtopic.php?t=3387