-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2082 from stack-of-tasks/topic/urdf_memory_leak
Topic/urdf memory leak
- Loading branch information
Showing
5 changed files
with
114 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
unittest/python/bindings_build_geom_from_urdf_memorycheck.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import os | ||
import unittest | ||
|
||
import pinocchio as pin | ||
|
||
|
||
@unittest.skipUnless(pin.WITH_URDFDOM, "Needs URDFDOM") | ||
class TestBuildGeomFromUrdfMemoryCheck(unittest.TestCase): | ||
def setUp(self): | ||
self.current_file = os.path.dirname(str(os.path.abspath(__file__))) | ||
self.model_dir = os.path.abspath( | ||
os.path.join(self.current_file, "../../models/example-robot-data/robots") | ||
) | ||
self.model_path = os.path.abspath( | ||
os.path.join(self.model_dir, "ur_description/urdf/ur5_robot.urdf") | ||
) | ||
|
||
def test_load(self): | ||
model = pin.buildModelFromUrdf(self.model_path) | ||
for _ in range(2): | ||
pin.buildGeomFromUrdf( | ||
model, | ||
self.model_path, | ||
pin.COLLISION, | ||
package_dirs=self.model_dir, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
SET(PYTHON_EXECUTABLE @PYTHON_EXECUTABLE@) | ||
SET(MEMORYCHECK_COMMAND @MEMORYCHECK_COMMAND@) | ||
SET(PYTHON_TEST_SCRIPT @PYTHON_TEST_SCRIPT@) | ||
|
||
execute_process(COMMAND | ||
${MEMORYCHECK_COMMAND} -- ${PYTHON_EXECUTABLE} ${PYTHON_TEST_SCRIPT} | ||
ERROR_VARIABLE MEMORYCHECK_OUTPUT) | ||
|
||
string(FIND "${MEMORYCHECK_OUTPUT}" "definitely lost: 0 bytes in 0 blocks" DEFINITELY_LOST) | ||
string(FIND "${MEMORYCHECK_OUTPUT}" "indirectly lost: 0 bytes in 0 blocks" INDIRECTLY_LOST) | ||
|
||
if(${DEFINITELY_LOST} GREATER -1 AND ${INDIRECTLY_LOST} GREATER -1) | ||
message(STATUS "${PYTHON_TEST_SCRIPT} is not leaking memory") | ||
else() | ||
message(FATAL_ERROR "Output: ${MEMORYCHECK_OUTPUT}\n" | ||
"${PYTHON_TEST_SCRIPT} is leaking memory\n") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters