You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to test my robot in different terrains. So I create these terrains using the Python function createCollisionShape and destroy them using the function removeBody. However, when creating and destroying objects frequently, memory usage increased rapidly.
The minimal code is provided below.
import pybullet as p
import numpy as np
import psutil
p.connect(p.DIRECT)
def f():
height_field = np.zeros((1000, 1000))
terrain_shape = p.createCollisionShape(
shapeType=p.GEOM_HEIGHTFIELD,
heightfieldData=height_field.transpose().flatten(),
numHeightfieldRows=height_field.shape[0],
numHeightfieldColumns=height_field.shape[1])
terrain_id = p.createMultiBody(baseMass=0,
baseCollisionShapeIndex=terrain_shape,
basePosition=(0, 0, 0))
p.removeBody(terrain_id)
for i in range(1000):
f()
mem = psutil.virtual_memory()
print(f"Epoch {i}: {mem.used / 1024 / 1024:.1f}MB ({mem.percent}%)")
The results are:
Version:
- pybullet: 3.0.8
- numpy: 1.20.1
Is it possible to release the memory when destroyed the objects?
Any help is appreciated.
--------------------------------update------------------------------
I also tried to remove the collision shape using the function removeCollisionShape, but I failed.
The terminal gave me a warning message as shown below.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to test my robot in different terrains. So I create these terrains using the Python function
createCollisionShape
and destroy them using the functionremoveBody
. However, when creating and destroying objects frequently, memory usage increased rapidly.The minimal code is provided below.
The results are:

Version:
- pybullet: 3.0.8
- numpy: 1.20.1
Is it possible to release the memory when destroyed the objects?
Any help is appreciated.
--------------------------------update------------------------------
I also tried to remove the collision shape using the function
removeCollisionShape
, but I failed.The terminal gave me a warning message as shown below.
Beta Was this translation helpful? Give feedback.
All reactions