Dear all,
since starting to create route segments, I experienced Golden Cheetah being killed by the OS (Linux in my case) on a regular basis because of the huge amount of allocated memory. This usually happens after the creation of 3-4 new route segments.
I think I found the leaking code (see also the attached diff):
The method "void RideFile::appendOrUpdatePoint(double ..., bool forceAppend)" allocates a RideFilePoint twice and ignores the first instance if forceAppend is true.
Additionally replacing a RideFilePoint leaks memory in a similar way (creating a new instance of the point, forgetting the pointer to the original without deleting). According to my logs this didn't happen to me, nevertheless I included a fix in my patch.
This leak is relevant in every situation where activities are loaded, not only when creating route segments.
My measurements gave me the number of up to 4GB of leaked memory per created route segment. After applying my fix, the memory usage increased only slightly during this task, resulting in improved stability and user experience.
According to
https://github.com/GoldenCheetah/GoldenCheetah/issues/2635 the activities should be kept in memory after being read once. Therefore I still have the open question why they are being re-read over and over again. Is this an issue you guys think I could and should investigate - is it worth it?
I am aware of the nearing 3.6 release and the necessary caution not to introduce regressions. Nevertheless I see this as a change that can increase stability of Golden Cheetah significantly. If you consider it to risky at the moment, please consider applying it after the release.
Regards
Joachim