Possible memory leak - performance issues

H222

Well-known member
Has anybody noticed any degradation of performance over time in Trainz22 or Trainz+? On a very large route of mine - and a few others - I have noticed that the game starts out with full FPS and has no problems loading the route with full draw distance and next to no shuddering. Give it half an hour and the route is now at 1 FPS. It slowly starts to lower from 30 Frames (with Vsync), down to approx 25, and then very rapidly gets down to single digits and near freezing.

This is happening on barely sceniced sections, with a very wide baseboard length (PBR textures where they’ve been used, but still some non-PBR DEM textures as well). I have tried changing out assets, changing the scale of textures to max with the idea it renders them less, removed TRC crossings from the route, removed all TurfFX and Clutter 1.0 from the route, removed 99% of grass splines, and still I get this same lag bug after about half an hour. Within the exact same section of the route I’d be at full FPS if I’d freshly restarted trainz or my computer, I’m seeing practically 0 FPS.

Safe to say it’s very frustrating. I’ve been dealing with this for approximately a year, but have been trying to fix it myself with different assets and the above listed fixes but I’m starting to suspect it’s trainz related. I have a 3060 that during this, is barely operating (normally around 30%), whilst my 32 gig of RAM is regularly maxing out.

Cheers
Jamie
 
I've witnessed that too. It could be scripted assets not clearing the memory once the script has stopped running. I haven't seen this with TRC 4 assets, but I have seen it with interactive industries when there are lots of them, and when there are lots of signals.

Is it worse in your sessions?

I had an issue due to some bad scripts used for some nice-looking passenger cars. They had some kind of script in them for lighting and door operation that hogged the system right down causing the track to display in clumps or not at all unless I hit pause to get the track to load. The sessions would work fine for about a half hour then everything got slower and slower until nothing worked any longer.
 
probably just another stack overflow error:

error-404.gif
 
@H222 - Recommend increase your Virtual Memory to provide more resilience in these events. If you have 32Gb DDR4 or 5 RAM, then allocating 64Gb or more of PageFile memory on your fastest SSD is definitely helpful for smooth Trainz database and merge operations. Mine is set to 96Gb spread over a couple of SSDs (to reduce wear). Having memory overhead makes a huge difference with all versions of Trainz.
 
There is no function I know of that will deliberately release memory although I suppose setting an object reference or a list of objects to null should indicate that the memory can be recovered. No idea if Trainz or Windows manages that. Probably Trainz as all that should be in Trainz allocated memory space.

My inclination would be to report it to N3V as a problem and be prepared to give them your route and whatever session is causing the problem. I'm sure they have tools to work out where the memory is being used because they must have used some analysis to determine the Trainzscript functions they obsoleted, These are those scripts that constantly get lists of vehicles in a train, signals, junctions, and similar.

The OP might also try running the route and session in Compatibility Mode - Show errors on legacy calls. Turn on the debug stuff at the same time and look at the logs. If there are problem assets then the log will likely be full of errors caused by old scripts. They will identify the assets concerned that might need attention.

I wouldn't save the route or session after doing that just to be safe. You might also back up your route and session(s) to CDPs prior to running that test. Revert to Maximise Compatibility and turn off the debug stuff unless you need it.
 
I have Trainz Plus build 126280 with the same problems on my large routes. In Surveyor, it seems to be the result of moving around the route a lot vs working in a small area. Never had this problem in older versions of Trainz.

Increasing my PCs RAM from 16 to 32gb did not entirely solve the problem. One symptom is that, in Surveyor, track and road splines no longer redraw when you move spline points. So, you have spline points that are no longer on what appears to be the spline. When this happens, the only solution I have found is to save, exit, and restart Trainz.

I believe the cache function is not working correctly and over time, I run out of memory. If N3V would compare the code that manages the cache in new versions vs older versions, they could find the problem.
 
Last edited:
I don't remember when Nvidia enabled the creation of its own cache in the control panel (It seems like a year or two ago).
The game can create its own cache, and there may be a conflict between two different caches.
Try disabling Nvidia cache creation and then completely deleting all Nvidia cache files:

 
Last edited:
The closest thing I've encountered to this is the smoothness from different Trainz versions. So if I was using an older route it would run better on TS2009 or T:ANE than TRS2019 or TRS2022.
 
I have noticed it on another route I have, if I were to place down a larger consist of more than 5 to 6 carriages/wagons the game lags big time as soon as I click on drive session and I haven't figured out why. It's really frustrating

EDIT: I even maxed out the full settings in NVIDIA control panel and the lag continued
 
I bought the 32GB (16GBx2) Modules from Crucial for my Laptop maybe a week ago. TRAINZ needs the memory badly. I currently have 8GB.
It's sitting on my desk. Why don't I just install it?
I'm afraid of my life getting too better too quickly.
 
i even notice the Game lags really bad when i hit drive after working in Surveyor Classic... The Game even seems to lag bad even with 64GB of Ram installed while running a Ryzen 5 5600G Quad Core Processor running at 4.0Ghz using only 10% of the CPU under load... i am even having hard time running the game as well in Driver...
 
i even notice the Game lags really bad when i hit drive after working in Surveyor Classic... The Game even seems to lag bad even with 64GB of Ram installed while running a Ryzen 5 5600G Quad Core Processor running at 4.0Ghz using only 10% of the CPU under load... i am even having hard time running the game as well in Driver...
And what is your GPU (video card) paired up with your Ryzen CPU (processor)?
 
After several hours of working Surveyor, I noticed the screen would spontaneously refresh and then without me doing anything, it would refresh again. All objects and terrain would disappear only to be slowly redrawn. This in a an extra large route, >1500 MB in Trainz22PE 129335. The only way to stop the cycle is to close and restart.
 
Back
Top