-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Memory leak when rendering (camera / UI) in PG map with multiple scen…
…arios (#656) * update a minimal reproducible script * remove cache height map and semantic map in Map instance * rename test script
- Loading branch information
1 parent
c326ae5
commit 6504392
Showing
3 changed files
with
153 additions
and
107 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
38 changes: 38 additions & 0 deletions
38
metadrive/tests/local_tests/local_test_memory_leak_with_rendering.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,38 @@ | ||
""" | ||
We find running rendering (windows or RGB camera) with PG env with multiple scenarios has severe memory leak. | ||
""" | ||
from metadrive.component.sensors.rgb_camera import RGBCamera | ||
from metadrive.envs.metadrive_env import MetaDriveEnv | ||
|
||
|
||
def test_safe_env_memory_leak(): | ||
# Initialize environment | ||
train_env_config = dict( | ||
# manual_control=False, # Allow receiving control signal from external device | ||
# window_size=(200, 200), | ||
horizon=1500, | ||
# use_render=vis, | ||
image_observation=True, | ||
sensors=dict(rgb_camera=(RGBCamera, 256, 256)), | ||
num_scenarios=100, | ||
) | ||
|
||
env = MetaDriveEnv(train_env_config) | ||
try: | ||
total_cost = 0 | ||
for ep in range(20): | ||
o, _ = env.reset() | ||
env.engine.force_fps.disable() | ||
for i in range(1, 1000): | ||
o, r, tm, tc, info = env.step([0, 1]) | ||
total_cost += info["cost"] | ||
assert env.observation_space.contains(o) | ||
if tm or tc: | ||
total_cost = 0 | ||
break | ||
finally: | ||
env.close() | ||
|
||
|
||
if __name__ == '__main__': | ||
test_safe_env_memory_leak() |