Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

car_racing.py memory leaking issue #2062

Closed
jackyoung96 opened this issue Oct 5, 2020 · 3 comments · Fixed by xeviknal/gym#1
Closed

car_racing.py memory leaking issue #2062

jackyoung96 opened this issue Oct 5, 2020 · 3 comments · Fixed by xeviknal/gym#1

Comments

@jackyoung96
Copy link
Contributor

vl = pyglet.graphics.vertex_list(

There is memory leaking in car_racing.py code.

pyglet.graphics.vertex_list() function makes the memory almost double,

And it can be fixed with vl.delete() under this line

vl.draw(gl.GL_QUADS)

@praveenVnktsh
Copy link

Thanks a lot. This fixed the leak issue.

@Jaekyung-Cho I guess it would be great if you could submit a pull request for this.

@JunkyByte
Copy link

JunkyByte commented Nov 18, 2020

Hello, I've experienced the same memory leak and applied the solution given by @Jaekyung-Cho.
While it reduces the problem (greatly) it does not eliminate it, I'm running out of ram pretty quickly using multiple CarRacing environments in parallel (on a 64gb ram machine).

Could you share your results for the following code? I see constant increase in ram usage.
(For fair comparison I'm sharing a single environment test code to reproduce so that there's no doubt that it is related to gym / CarRacing env).

import gym
import psutil
import os

def memory_used():
    return psutil.Process(os.getpid()).memory_info().rss * 1e-6  # To megabyte

e = gym.make('CarRacing-v0')
e.unwrapped.verbose = 0

for i in range(10000000):
    e.reset()

    if i % 1000 == 0:
        print('Ram Used: %f' % memory_used())

which outputs (numbers are megabyte)

Ram Used: 153.264128
Ram Used: 172.523520
Ram Used: 181.149696
Ram Used: 181.149696
Ram Used: 197.632000
Ram Used: 197.632000
Ram Used: 197.632000
Ram Used: 202.498048
Ram Used: 204.931072
Ram Used: 226.336768
Ram Used: 229.040128
Ram Used: 231.743488
Ram Used: 234.176512
Ram Used: 236.609536
Ram Used: 239.312896
Ram Used: 241.745920
Ram Used: 244.449280
Ram Used: 280.604672
Ram Used: 283.037696
(...)

looking for a solution, would you be so kind to tell me if you are able to reproduce the issue?

@jackyoung96
Copy link
Contributor Author

jackyoung96 commented Nov 19, 2020

Hello, I've experienced the same memory leak and applied the solution given by @Jaekyung-Cho.
While it reduces the problem (greatly) it does not eliminate it, I'm running out of ram pretty quickly using multiple CarRacing environments in parallel (on a 64gb ram machine).

Could you share your results for the following code? I see constant increase in ram usage.
(For fair comparison I'm sharing a single environment test code to reproduce so that there's no doubt that it is related to gym / CarRacing env).

import gym
import psutil
import os

def memory_used():
    return psutil.Process(os.getpid()).memory_info().rss * 1e-6  # To megabyte

e = gym.make('CarRacing-v0')
e.unwrapped.verbose = 0

for i in range(10000000):
    e.reset()

    if i % 1000 == 0:
        print('Ram Used: %f' % memory_used())

which outputs (numbers are megabyte)

Ram Used: 153.264128
Ram Used: 172.523520
Ram Used: 181.149696
Ram Used: 181.149696
Ram Used: 197.632000
Ram Used: 197.632000
Ram Used: 197.632000
Ram Used: 202.498048
Ram Used: 204.931072
Ram Used: 226.336768
Ram Used: 229.040128
Ram Used: 231.743488
Ram Used: 234.176512
Ram Used: 236.609536
Ram Used: 239.312896
Ram Used: 241.745920
Ram Used: 244.449280
Ram Used: 280.604672
Ram Used: 283.037696
(...)

looking for a solution, would you be so kind to tell me if you are able to reproduce the issue?

Ram Used: 173.060096
Ram Used: 181.374976
Ram Used: 181.428224
Ram Used: 196.329472
Ram Used: 194.228224
Ram Used: 196.370432
Ram Used: 198.959104
Ram Used: 201.515008
Ram Used: 218.734592
Ram Used: 221.319168
Ram Used: 223.891456
Ram Used: 226.594816
Ram Used: 229.027840
Ram Used: 231.723008
Ram Used: 234.295296
Ram Used: 236.916736
Ram Used: 268.730368
Ram Used: 271.433728
Ram Used: 273.866752
Ram Used: 276.467712
Ram Used: 279.158784
Ram Used: 281.751552

I also got same result.

In my case, I didn't run car_racing module more than 24 hours. And that's why I didn't care about this RAM memory leaking.

Anyway, thank you for notice me and I try to solve it!!!

NighTurs added a commit to NighTurs/gym that referenced this issue Jan 22, 2021
pull request about issue openai#2062 (car_racing.py memory leaking issue )
pzhokhov pushed a commit that referenced this issue Feb 16, 2021
…2096)

* car_racing.py memory leaking issue #2062 solving

* additional memory leaking resolve
zlig pushed a commit to zlig/gym that referenced this issue Sep 6, 2021
…sue ) (openai#2096)

* car_racing.py memory leaking issue openai#2062 solving

* additional memory leaking resolve
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants