Jump to content

You're browsing the 2004-2023 VATSIM Forums archive. All content is preserved in a read-only fashion.
For the latest forum posts, please visit https://forum.vatsim.net.

Need to find something? Use the Google search below.

vPilot memory and CPU usage higher, causing performance issues in P3Dv5


Bryn Battersby
 Share

Recommended Posts

Bryn Battersby
Posted
Posted

Hi,

With recent versions of vPilot (including 2.6.10), I've noticed the memory and CPU usage seems to be a lot higher, especially the longer it has been open. After a two hour flight from Long Beach to Tahoe, the memory footprint was 800mb, and it was taking up around 5% of CPU. It was also creating stutters in the P3D, which cleared up as soon as I closed vPilot.  Has something changed that could induce what looks like a memory link? 

I usually fly using Vatsim with Live Traffic, and with parked AI at departure and destination, which requires looping automatic deletion of airborne AI, and I thought this might be causing the problem - i.e., perhaps you are keeping a table of simobjects that is not cleaned up when they are deleted from the sim. But I've just been sitting here with all of that turned off for the last hour, watching the memory footprint creep up, along with CPU usage (which starts around 0.8-0.9%).  Also, when I disconnect from VATSIM, the CPU usage does not fall - it stays high. Only closing vPilot and restarting it works to rest the CPU usage to normal levels.

Any ideas?

Bryn.

Link to comment
Share on other sites

Ross Carlson
Posted
Posted

You mentioned this is happening with recent versions ... which version did it start with?

Developer: vPilot, VRC, vSTARS, vERAM, VAT-Spy

Senior Controller, Boston Virtual ARTCC

Link to comment
Share on other sites

Bryn Battersby
Posted
Posted

Hi Ross, Thanks - I tested it this afternoon by rolling back to 2.5.1, which I think was the first version to identify P3Dv5. I had the same problem with that version too - the memory slowly creeped up over time and CPU usage increased. I guess my question is what would be causing vPilot to continue use so much RAM and so many CPU cycles after it has disconnected from VATSIM, but while the sim is still running?

Link to comment
Share on other sites

Ross Carlson
Posted
Posted
2 hours ago, Bryn Battersby 848612 said:

Hi Ross, Thanks - I tested it this afternoon by rolling back to 2.5.1, which I think was the first version to identify P3Dv5. I had the same problem with that version too - the memory slowly creeped up over time and CPU usage increased. I guess my question is what would be causing vPilot to continue use so much RAM and so many CPU cycles after it has disconnected from VATSIM, but while the sim is still running?

I can't think of anything, and I haven't had any other reports. There's nothing in the code that uses memory and never releases it.

Have you ever NOT had this problem?

Developer: vPilot, VRC, vSTARS, vERAM, VAT-Spy

Senior Controller, Boston Virtual ARTCC

Link to comment
Share on other sites

Ross Carlson
Posted
Posted

Bryn, note that I am aware of a memory leak in the managed SimConnect library, which vPilot uses. It seems the lib does not release memory of a struct that is passed to it to update SimObject variables. vPilot does this to update the position of each nearby aircraft. It calls the SetDataOnSimObject method for each aircraft, every frame, to achieve smooth aircraft movement with interpolation. This does cause the memory usage to creep up slowly over time, but only if you have a lot of aircraft around you. If you have no aircraft nearby, the memory usage stays flat. During your 2 hour flight from Long Beach to Tahoe, were you surrounded by lots of other aircraft?

Note that this does not seem to cause high CPU usage, so it doesn't quite explain your symptoms.

Developer: vPilot, VRC, vSTARS, vERAM, VAT-Spy

Senior Controller, Boston Virtual ARTCC

Link to comment
Share on other sites

Bryn Battersby
Posted
Posted

Hi Ross,

Thanks for your generosity in taking the time to respond to this. I think I've nailed it down. I observe the creep in memory usage that you noted, which is faster in dense traffic areas, but this doesn't explain such high memory footprint and CPU usage at the end of a flight. However, your comment that this has not be otherwise reported made me look more closely at my own setup.

It looks like one of my other programs accelerates the vPilot memory usage and CPU usage by occasionally repetitively deleting a vPilot-created simObject whenever it is created. When this happens, the CPU usage and memory usage of vPilot begins to spiral. I've rewritten my other program to be more careful about what it deletes, and it seems to be working OK so far.

There are other programs out there that will delete simObjects for performance, so if it comes up again, this could be the cause.

Thanks again,

Bryn.

 

Link to comment
Share on other sites

Ross Carlson
Posted
Posted (edited)
4 hours ago, Bryn Battersby 848612 said:

It looks like one of my other programs accelerates the vPilot memory usage and CPU usage by occasionally repetitively deleting a vPilot-created simObject whenever it is created. When this happens, the CPU usage and memory usage of vPilot begins to spiral.

Thanks for reporting back with what you found. I took a look at the vPilot code, and it does subscribe to the SimConnect ObjectAddremove event, and it does remove the aircraft object from my list of aircraft, but I found another location where a reference to the object was still being held, in the case where the object is deleted by some other SimConnect client, or by the simulator itself. I'll add code to remove that other reference in the next build.

Out of curiosity, why do you sometimes delete objects in your other software?

Edited by Ross Carlson

Developer: vPilot, VRC, vSTARS, vERAM, VAT-Spy

Senior Controller, Boston Virtual ARTCC

Link to comment
Share on other sites

Bryn Battersby
Posted
Posted

Thanks Ross, I keep all my installed AI on when I fly with vpilot, but I delete any AI that isn’t parked. That keeps my airports looking interesting and alive. I also delete AI that are parked in the same spot as a vPilot injected aircraft. That’s where my problem was. I was unintentionally deleting vPilot injected aircraft if two vPilot aircraft were occupying the same spot. Cheers, Bryn. 

Link to comment
Share on other sites

Ross Carlson
Posted
Posted

Ahh, cool. Thanks.

Developer: vPilot, VRC, vSTARS, vERAM, VAT-Spy

Senior Controller, Boston Virtual ARTCC

Link to comment
Share on other sites

 Share