openai / procgen

Procgen Benchmark: Procedurally-Generated Game-Like Gym-Environments
https://openai.com/blog/procgen-benchmark/
MIT License
991 stars 207 forks source link

Memory leak on destruction of ProcgenGym3Env #68

Open jordan-schneider opened 2 years ago

jordan-schneider commented 2 years ago

The following produces a memory leak

# leak.py
from procgen.env import ProcgenGym3Env
import numpy as np

n_envs = 100_000
timesteps = 10

for _ in range(n_miners):
        env = ProcgenGym3Env(1, "miner")
        for t in range(timesteps):
            env.act(np.array([5]))
            env.observe()
            env.get_info()

One can see this leak by installing memory-profiler

pip install memory-profiler

and running the mprof utility

mprof run -o multiple-envs-100000-10.dat leak.py; mprof plot -o leak.png multiple-envs-100000-10.dat