Permanently Removing Objects from Simulation?

Typically: "How do I... ", "How can I... " questions
Post Reply
Matt
Posts: 10
Joined: 02 Feb 2016, 21:33

Permanently Removing Objects from Simulation?

Post by Matt » 27 Sep 2017, 19:46

Hi there,

I have an application where I'm adding / removing hundreds of different objects from a V-REP scene, but finding that although an object can be "removed" from the scene, data still persists in memory which eventually ends up maxing out my RAM. Here's a snippit that'll reproduce it, where Cap.stl is from https://free3d.com/download-page.php?url=sport-cap-6044

Code: Select all

while simGetSimulationState()~=sim_simulation_advancing_abouttostop do
    local object = simImportShape(4, 'Cap.stl', 1+2, 0.01, 1.)
    simSwitchThread() 
    simRemoveObject(object)
end
Is there a known workaround for this?

Thanks!
Matt

coppelia
Site Admin
Posts: 7120
Joined: 14 Dec 2012, 00:25

Re: Permanently Removing Objects from Simulation?

Post by coppelia » 29 Sep 2017, 18:49

Hello Matt,

you discovered a memory leak with the import function. You can work around it by importing the item once, then simply copy/pasting it as needed (if the object is always the same):

Code: Select all

local a=sim.getObjectHandle('Shape')
while simGetSimulationState()~=sim_simulation_advancing_abouttostop do
    local objects = sim.copyPasteObjects({a},0)
    simSwitchThread()
    simRemoveObject(objects[1])
end
Cheers

Matt
Posts: 10
Joined: 02 Feb 2016, 21:33

Re: Permanently Removing Objects from Simulation?

Post by Matt » 30 Sep 2017, 03:51

Thanks for the confirmation. I'll see what I can do to avoid loading different objects too frequently in the meantime!

Matt

Post Reply