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

Memory leak with GSTown::FoundTown #5870

Closed
DorpsGek opened this issue Jan 20, 2014 · 6 comments
Closed

Memory leak with GSTown::FoundTown #5870

DorpsGek opened this issue Jan 20, 2014 · 6 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

R2dical opened the ticket and wrote:

I reported this issue a while ago in the development thread, but now seem to have specific enough info to report here.

Anyway, using this function in even the most basic of GS causes a large, linear increase in RAM footprint and if continued will crash OpenTTD.
It seems somewhat related to how town names are handled as passing in null as per default instead of a specific string makes the symptoms worse.

Attached is a very simple GS to demonstrate, LeakGS, which has a line to comment out to switch between random and specified names. With specific names I can watch ram cache for Openttd grow to ~2GB then crash, with random (null) it will just freeze after a while. Best results on a 2048*2 map.

Hoping that can narrow it down :)

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/5870
@DorpsGek
Copy link
Member Author

frosch wrote:

I let the script run. After 6 months is finishes the town_count loop and exits.

I do not observe any high memory usage. Valgrind does not report any issues either.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5870#comment12936

@DorpsGek
Copy link
Member Author

R2dical wrote:

Thanks for taking a look, so after poking at this for a long time, including seeing it happen both on my desktop and laptop I reinstalled a fresh OpenTTD and think I found the issue.
My cfg file used for ages seems to cause it when combined with the script and trunk OpenTTD.

Using this .cfg with the script causes the leak + crash, new cfg + script = no problem...
So solved maybe, but could still point to an issue somewhere?

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5870#comment12938

@DorpsGek
Copy link
Member Author

LordAro wrote:

Cannot reproduce, even with the .cfg


This comment was imported from FlySpray: https://bugs.openttd.org/task/5870#comment13047

@DorpsGek
Copy link
Member Author

R2dical wrote:

Hmm, I can again repeat this, key being the .cfg.
Compiled r26276 myself but from unmodified source, though it has presented in older versions.
Of note is that OpenTTD didn't even generate crash reports.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5870#comment13054

@DorpsGek
Copy link
Member Author

MJP wrote:

I confirm the high memory usage, it is not a leak but a heavy use of the cache.

With the "leak" GS and "town_name = french", no town were created on a 1024*1024 map... due to lack of available french town names!

I set town_name = english then plenty of "abcd*" towns are created and the memory used rises fast (to get an error sort of "out of capacity" before 2gb (64bits binary)).

I patched ScriptTown::FoundTown() to call GenerateTownName() only when it should (I let CmdFoundTown() handle IsUniqueTownName()). With that, "town_name = french" is not a problem anymore.

I try again the "leak" GS and the memory problem is gone. So I believe GenerateTownName() is the one to abuse the cache.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5870#comment13055

@DorpsGek
Copy link
Member Author

frosch closed the ticket.

Reason for closing: Fixed

in r26356. Thanks MJP!


This comment was imported from FlySpray: https://bugs.openttd.org/task/5870

@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) bug labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant