-
Notifications
You must be signed in to change notification settings - Fork 532
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
Memory leak fix. #156
Memory leak fix. #156
Conversation
It's not clear to me what |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd cache the strdup'd version on the Emulator class (check if it's null and call corePath() if it is) and delete it at destruction time. It never changes after the first call so this is safe. That said, because it's not changed I'm not sure the buffer will ever be invalidated, so the original version may already be safe. It's not entirely clear to me, given C++'s wishy-washy memory safety guarantees.
@endrift @christopherhesse I made the requested change. Could you please take another look? Also, what is role of |
Retro is nice if you want consistency with other retro games, but ALE is faster, see #127 |
51efee0
to
f0c96be
Compare
Thanks for the quick response! Are there plans to tackle the issues mentioned in that post? Also, when you say faster, what kind of difference have you measured? Is it significant? |
I don't remember, but I believe it is significant, something like 2-3x faster per frame for ALE. If you use a large model or have a lot of CPUs, maybe it doesn't matter as much, but there's definitely a speed difference. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm now
Thanks @endrift and @eaplatanios! |
This is pulled out of #152 as @endrift suggested. I'm not sure if it's ok now even though I get no errors when I check it with valgrind (I was getting errors when I wasn't using
strdup
). Who is supposed to own the memory pointed to bydata
and free it? @endrift do you have any suggestions?