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

Skidmarks memory leak #343

Closed
Max98 opened this Issue Jul 29, 2015 · 14 comments

Comments

Projects
None yet
4 participants
@Max98
Contributor

Max98 commented Jul 29, 2015

I've been having some people telling me that they experience FPS drop the more time they play, so I knew it was a memory leak, but where it came from? No idea.
Lately, I've been working on shadows and I started to notice that my fps was going down only when driving a car. So I've started disabling stuff until I arrived to skidmarks. Diasbling them gave me a steady 60FPS while doing a lap on the F1_track while keeping them enabled will give me 16 FPS at the end of the lap.

It would be great if one you ( @Hiradur @only-a-ptr @skybon ) could take a look at this, I do not have knowledge on debugging memory leaks sadly.

@Max98 Max98 added this to the RoR 0.4.5 (Nextstable) milestone Jul 29, 2015

@only-a-ptr

This comment has been minimized.

Show comment
Hide comment
@only-a-ptr

only-a-ptr Jul 29, 2015

Member

@Max98 Please post links to the track and vehicle you tested with.
I checked the code but didn't find any opportunity for memleak. The only dyn-allocated objects are Ogre::ManualObject, but those are properly destroyed.
It's possible this is a memory-hogging case rather than memory-leaking case. Someone pls review "SkidmarksBuckets (count)" config option, set it to 1, do a test drive and check RoR's memory usage in system task manager.
@Hiradur Please check this in Valgrind

Member

only-a-ptr commented Jul 29, 2015

@Max98 Please post links to the track and vehicle you tested with.
I checked the code but didn't find any opportunity for memleak. The only dyn-allocated objects are Ogre::ManualObject, but those are properly destroyed.
It's possible this is a memory-hogging case rather than memory-leaking case. Someone pls review "SkidmarksBuckets (count)" config option, set it to 1, do a test drive and check RoR's memory usage in system task manager.
@Hiradur Please check this in Valgrind

@Hiradur

This comment has been minimized.

Show comment
Hide comment
@Hiradur

Hiradur Jul 29, 2015

Contributor

I can confirm this. I made a few laps with EL_BRUTE (http://www.rigsofrods.com/attachment.php?attachmentid=313472&d=1336206992) on the f1 track (http://www.rigsofrods.com/repository/view/3739).

I noticed:
At the beginning: 400+ FPS
After 2 laps without skidmarks: 400+ FPS

After 1 lap with skidmarks: 90 FPS
After 5 laps with skidmarks: 90 FPS

EDIT: This was with SkidmarksBuckets undefined in RoR.cfg so the default value was used.

So at some point FPS don't decrease anymore. Perhaps this is the threshhold where old skidmarks get cleaned up?
Debugging in Valgrind will be a bit tricky because the game runs at very low FPS. I'll see what I can do.

Contributor

Hiradur commented Jul 29, 2015

I can confirm this. I made a few laps with EL_BRUTE (http://www.rigsofrods.com/attachment.php?attachmentid=313472&d=1336206992) on the f1 track (http://www.rigsofrods.com/repository/view/3739).

I noticed:
At the beginning: 400+ FPS
After 2 laps without skidmarks: 400+ FPS

After 1 lap with skidmarks: 90 FPS
After 5 laps with skidmarks: 90 FPS

EDIT: This was with SkidmarksBuckets undefined in RoR.cfg so the default value was used.

So at some point FPS don't decrease anymore. Perhaps this is the threshhold where old skidmarks get cleaned up?
Debugging in Valgrind will be a bit tricky because the game runs at very low FPS. I'll see what I can do.

@DirtGamer301

This comment has been minimized.

Show comment
Hide comment
@DirtGamer301

DirtGamer301 Jul 29, 2015

@Hiradur
Yes, after xy amount of skidmarks (idk how it's defined) old ones will get cleaned up.

For example set xy to 100 metres of skidmarks:
You drive and at some point you'll have reached the 100 metres of skidmarks on the road. From now on the first skidmarks will get deleted by the more new skidmarks you make. So if you now make 10 more metres skidmarks, the first 10 metres skidmarks will be gone.

I remember Max telling me some time ago that old skidmarks are being deleted at some point, the example was taken from my own experiences and tests including my knowledge form what Max told me.
He also said that there should be an option to set the highest amount of skidmarks in the game settings.

DirtGamer301 commented Jul 29, 2015

@Hiradur
Yes, after xy amount of skidmarks (idk how it's defined) old ones will get cleaned up.

For example set xy to 100 metres of skidmarks:
You drive and at some point you'll have reached the 100 metres of skidmarks on the road. From now on the first skidmarks will get deleted by the more new skidmarks you make. So if you now make 10 more metres skidmarks, the first 10 metres skidmarks will be gone.

I remember Max telling me some time ago that old skidmarks are being deleted at some point, the example was taken from my own experiences and tests including my knowledge form what Max told me.
He also said that there should be an option to set the highest amount of skidmarks in the game settings.

@Max98

This comment has been minimized.

Show comment
Hide comment
@Max98

Max98 Jul 29, 2015

Contributor

@only-a-ptr Any vehicle (Needs to be powerful enough to do skids) and any terrain with asphalt ground will do the job, just play for more than 5 mins.

As for me, I've been monitoring my FPS while doing a lap and It started at 50 fps, the more I progress on the lap, the more it goes down till 15 fps

Contributor

Max98 commented Jul 29, 2015

@only-a-ptr Any vehicle (Needs to be powerful enough to do skids) and any terrain with asphalt ground will do the job, just play for more than 5 mins.

As for me, I've been monitoring my FPS while doing a lap and It started at 50 fps, the more I progress on the lap, the more it goes down till 15 fps

@only-a-ptr

This comment has been minimized.

Show comment
Hide comment
@only-a-ptr

only-a-ptr Jul 29, 2015

Member

Quick investigation from GitHub web interface (I'm at work)

Skidmarks are organized into Buckets, which are put on Queue. After the queue reaches maximum size (default 200, configured by "SkidmarksBuckets"), old buckets are deleted. Each bucket contains an Ogre::ManualObject of 300 vertices (polygon mode is TRIANGLE_STRIP, so first 3 verts form a triange and every next vert forms another).

The default bucket limit 200 is set here https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/physics/Beam.cpp#L3039 and IMO it's pretty huge. With 300 verts per bucket, that's (300-2)*200 = 59 600 polys! With the default viewing distance of skidmarks being 2km (https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.cpp#L190), the slowdown may just as well come from OGRE itself having to process all this stuff. I thought the bottleneck is culling, but that's disabled for skidmarks: https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.cpp#L183. There is also AABB updating code in place https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.cpp#L397 so OGRE should properly skip unseen skidmaks from rendering, but that would result in varying FPS stalls (depending on point of view), whereas we're dealing with constant drop.

Hope this helps a bit. Gotta get back to work now.

Member

only-a-ptr commented Jul 29, 2015

Quick investigation from GitHub web interface (I'm at work)

Skidmarks are organized into Buckets, which are put on Queue. After the queue reaches maximum size (default 200, configured by "SkidmarksBuckets"), old buckets are deleted. Each bucket contains an Ogre::ManualObject of 300 vertices (polygon mode is TRIANGLE_STRIP, so first 3 verts form a triange and every next vert forms another).

The default bucket limit 200 is set here https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/physics/Beam.cpp#L3039 and IMO it's pretty huge. With 300 verts per bucket, that's (300-2)*200 = 59 600 polys! With the default viewing distance of skidmarks being 2km (https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.cpp#L190), the slowdown may just as well come from OGRE itself having to process all this stuff. I thought the bottleneck is culling, but that's disabled for skidmarks: https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.cpp#L183. There is also AABB updating code in place https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.cpp#L397 so OGRE should properly skip unseen skidmaks from rendering, but that would result in varying FPS stalls (depending on point of view), whereas we're dealing with constant drop.

Hope this helps a bit. Gotta get back to work now.

@Hiradur

This comment has been minimized.

Show comment
Hide comment
@Hiradur

Hiradur Aug 1, 2015

Contributor

valgrind --leak-check=full --show-leak-kinds=all ./RoR
only passages containing "skidmark"

I suggest you start looking at the very last one, it's the biggest leak (accumulated?)

==3070== 32 bytes in 1 blocks are possibly lost in loss record 3,191 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x7682DCA: std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x76834CB: std::string::assign(std::string const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x5CECCB: SkidmarkManager::loadDefaultModels() (basic_string.h:547)
==3070==    by 0x5CF0FF: SkidmarkManager::SkidmarkManager() (Skidmark.cpp:34)
==3070==    by 0x5D0204: Skidmark::updatePoint() (Singleton.h:45)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563E920: Ogre::Root::_fireFrameStarted() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 104 bytes in 4 blocks are possibly lost in loss record 9,648 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x56D28AB: Ogre::StringConverter::toString(unsigned long, unsigned short, char, std::_Ios_Fmtflags) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x55D8486: Ogre::Pass::addTextureUnitState(Ogre::TextureUnitState*) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x55D8657: Ogre::Pass::createTextureUnitState(std::string const&, unsigned short) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5CFAEF: Skidmark::addObject(Ogre::Vector3, std::string) (Skidmark.cpp:178)
==3070==    by 0x5D0328: Skidmark::updatePoint() (Skidmark.cpp:248)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563E920: Ogre::Root::_fireFrameStarted() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 132 bytes in 4 blocks are possibly lost in loss record 10,324 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x508C260: char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) (in /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.54.0)
==3070==    by 0x7683D47: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x5558545: Ogre::Material::Material(Ogre::ResourceManager*, std::string const&, unsigned long long, std::string const&, bool, Ogre::ManualResourceLoader*) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5559545: Ogre::MaterialManager::createImpl(std::string const&, unsigned long long, std::string const&, bool, Ogre::ManualResourceLoader*, std::map<std::string, std::string, std::less<std::string>, Ogre::STLAllocator<std::pair<std::string const, std::string>, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > > const*) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5632CB2: Ogre::ResourceManager::create(std::string const&, std::string const&, bool, Ogre::ManualResourceLoader*, std::map<std::string, std::string, std::less<std::string>, Ogre::STLAllocator<std::pair<std::string const, std::string>, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > > const*) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5CF982: Skidmark::addObject(Ogre::Vector3, std::string) (Skidmark.cpp:175)
==3070==    by 0x5D0328: Skidmark::updatePoint() (Skidmark.cpp:248)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070== 156 bytes in 4 blocks are possibly lost in loss record 10,567 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x7C6E82: char* std::string::_S_construct<__gnu_cxx::__normal_iterator<char const*, std::string> >(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<char> const&, std::forward_iterator_tag) (basic_string.tcc:138)
==3070==    by 0x7C6EF1: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<__gnu_cxx::__normal_iterator<char const*, std::string> >(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<char> const&) (basic_string.h:1725)
==3070==    by 0x7C6F1A: _ZNK5boost9sub_matchIN9__gnu_cxx17__normal_iteratorIPKcSsEEEcvSbIcT_T0_EISt11char_traitsIcESaIcEEEv (sub_match.hpp:59)
==3070==    by 0x78D262: RigDef::Parser::ParseMeshWheel(std::string const&) (RigDef_Parser.cpp:2022)
==3070==    by 0x7B46A5: RigDef::Parser::ParseLine(std::string const&) (RigDef_Parser.cpp:1007)
==3070==    by 0x76EA83: Beam::LoadTruck(RoR::RigLoadingProfiler*, std::string const&, Ogre::SceneNode*, Ogre::Vector3 const&, Ogre::Quaternion&, collision_box_t*, bool, int) (Beam.cpp:6305)
==3070==    by 0x774282: Beam::Beam(int, Ogre::Vector3, Ogre::Quaternion, char const*, RoR::RigLoadingProfiler*, bool, bool, collision_box_t*, bool, std::vector<std::string, std::allocator<std::string> > const*, Skin*, bool, bool, int) (Beam.cpp:6128)
==3070==    by 0x7445C3: BeamFactory::CreateLocalRigInstance(Ogre::Vector3, Ogre::Quaternion, std::string, int, collision_box_t*, bool, std::vector<std::string, std::allocator<std::string> > const*, Skin*, bool, bool) (BeamFactory.cpp:224)
==3070==    by 0x55C96E: RoRFrameListener::InitTrucks(bool, std::string const&, int, std::string const&, std::vector<std::string, std::allocator<std::string> > const*, bool, Skin*) (RoRFrameListener.cpp:1161)
==3070==    by 0x562063: RoRFrameListener::updateEvents(float) (RoRFrameListener.cpp:935)
==3070== 
==3070== 157 bytes in 4 blocks are possibly lost in loss record 10,568 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x508C260: char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) (in /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.54.0)
==3070==    by 0x7683D47: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x5CF956: Skidmark::addObject(Ogre::Vector3, std::string) (Skidmark.cpp:175)
==3070==    by 0x5D0328: Skidmark::updatePoint() (Skidmark.cpp:248)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563E920: Ogre::Root::_fireFrameStarted() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563EA28: Ogre::Root::renderOneFrame() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 279 bytes in 9 blocks are possibly lost in loss record 12,201 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x7682395: std::string::_M_mutate(unsigned long, unsigned long, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x56CF799: Ogre::StringUtil::trim(std::string&, bool, bool) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5CE792: SkidmarkManager::processLine(std::vector<std::string, Ogre::STLAllocator<std::string, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >, std::string) (Skidmark.cpp:97)
==3070==    by 0x5CEDC7: SkidmarkManager::loadDefaultModels() (Skidmark.cpp:83)
==3070==    by 0x5CF0FF: SkidmarkManager::SkidmarkManager() (Skidmark.cpp:34)
==3070==    by 0x5D0204: Skidmark::updatePoint() (Singleton.h:45)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 309 bytes in 9 blocks are possibly lost in loss record 12,356 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x7682395: std::string::_M_mutate(unsigned long, unsigned long, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x56CF799: Ogre::StringUtil::trim(std::string&, bool, bool) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5CE7B8: SkidmarkManager::processLine(std::vector<std::string, Ogre::STLAllocator<std::string, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >, std::string) (Skidmark.cpp:99)
==3070==    by 0x5CEDC7: SkidmarkManager::loadDefaultModels() (Skidmark.cpp:83)
==3070==    by 0x5CF0FF: SkidmarkManager::SkidmarkManager() (Skidmark.cpp:34)
==3070==    by 0x5D0204: Skidmark::updatePoint() (Singleton.h:45)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 4,323 bytes in 131 blocks are possibly lost in loss record 15,081 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x508C260: char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) (in /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.54.0)
==3070==    by 0x7683D47: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x5558545: Ogre::Material::Material(Ogre::ResourceManager*, std::string const&, unsigned long long, std::string const&, bool, Ogre::ManualResourceLoader*) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5559545: Ogre::MaterialManager::createImpl(std::string const&, unsigned long long, std::string const&, bool, Ogre::ManualResourceLoader*, std::map<std::string, std::string, std::less<std::string>, Ogre::STLAllocator<std::pair<std::string const, std::string>, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > > const*) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5632CB2: Ogre::ResourceManager::create(std::string const&, std::string const&, bool, Ogre::ManualResourceLoader*, std::map<std::string, std::string, std::less<std::string>, Ogre::STLAllocator<std::pair<std::string const, std::string>, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > > const*) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5CF982: Skidmark::addObject(Ogre::Vector3, std::string) (Skidmark.cpp:175)
==3070==    by 0x5D09C5: Skidmark::updatePoint() (Skidmark.cpp:303)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
Contributor

Hiradur commented Aug 1, 2015

valgrind --leak-check=full --show-leak-kinds=all ./RoR
only passages containing "skidmark"

I suggest you start looking at the very last one, it's the biggest leak (accumulated?)

==3070== 32 bytes in 1 blocks are possibly lost in loss record 3,191 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x7682DCA: std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x76834CB: std::string::assign(std::string const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x5CECCB: SkidmarkManager::loadDefaultModels() (basic_string.h:547)
==3070==    by 0x5CF0FF: SkidmarkManager::SkidmarkManager() (Skidmark.cpp:34)
==3070==    by 0x5D0204: Skidmark::updatePoint() (Singleton.h:45)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563E920: Ogre::Root::_fireFrameStarted() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 104 bytes in 4 blocks are possibly lost in loss record 9,648 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x56D28AB: Ogre::StringConverter::toString(unsigned long, unsigned short, char, std::_Ios_Fmtflags) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x55D8486: Ogre::Pass::addTextureUnitState(Ogre::TextureUnitState*) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x55D8657: Ogre::Pass::createTextureUnitState(std::string const&, unsigned short) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5CFAEF: Skidmark::addObject(Ogre::Vector3, std::string) (Skidmark.cpp:178)
==3070==    by 0x5D0328: Skidmark::updatePoint() (Skidmark.cpp:248)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563E920: Ogre::Root::_fireFrameStarted() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 132 bytes in 4 blocks are possibly lost in loss record 10,324 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x508C260: char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) (in /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.54.0)
==3070==    by 0x7683D47: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x5558545: Ogre::Material::Material(Ogre::ResourceManager*, std::string const&, unsigned long long, std::string const&, bool, Ogre::ManualResourceLoader*) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5559545: Ogre::MaterialManager::createImpl(std::string const&, unsigned long long, std::string const&, bool, Ogre::ManualResourceLoader*, std::map<std::string, std::string, std::less<std::string>, Ogre::STLAllocator<std::pair<std::string const, std::string>, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > > const*) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5632CB2: Ogre::ResourceManager::create(std::string const&, std::string const&, bool, Ogre::ManualResourceLoader*, std::map<std::string, std::string, std::less<std::string>, Ogre::STLAllocator<std::pair<std::string const, std::string>, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > > const*) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5CF982: Skidmark::addObject(Ogre::Vector3, std::string) (Skidmark.cpp:175)
==3070==    by 0x5D0328: Skidmark::updatePoint() (Skidmark.cpp:248)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070== 156 bytes in 4 blocks are possibly lost in loss record 10,567 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x7C6E82: char* std::string::_S_construct<__gnu_cxx::__normal_iterator<char const*, std::string> >(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<char> const&, std::forward_iterator_tag) (basic_string.tcc:138)
==3070==    by 0x7C6EF1: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<__gnu_cxx::__normal_iterator<char const*, std::string> >(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<char> const&) (basic_string.h:1725)
==3070==    by 0x7C6F1A: _ZNK5boost9sub_matchIN9__gnu_cxx17__normal_iteratorIPKcSsEEEcvSbIcT_T0_EISt11char_traitsIcESaIcEEEv (sub_match.hpp:59)
==3070==    by 0x78D262: RigDef::Parser::ParseMeshWheel(std::string const&) (RigDef_Parser.cpp:2022)
==3070==    by 0x7B46A5: RigDef::Parser::ParseLine(std::string const&) (RigDef_Parser.cpp:1007)
==3070==    by 0x76EA83: Beam::LoadTruck(RoR::RigLoadingProfiler*, std::string const&, Ogre::SceneNode*, Ogre::Vector3 const&, Ogre::Quaternion&, collision_box_t*, bool, int) (Beam.cpp:6305)
==3070==    by 0x774282: Beam::Beam(int, Ogre::Vector3, Ogre::Quaternion, char const*, RoR::RigLoadingProfiler*, bool, bool, collision_box_t*, bool, std::vector<std::string, std::allocator<std::string> > const*, Skin*, bool, bool, int) (Beam.cpp:6128)
==3070==    by 0x7445C3: BeamFactory::CreateLocalRigInstance(Ogre::Vector3, Ogre::Quaternion, std::string, int, collision_box_t*, bool, std::vector<std::string, std::allocator<std::string> > const*, Skin*, bool, bool) (BeamFactory.cpp:224)
==3070==    by 0x55C96E: RoRFrameListener::InitTrucks(bool, std::string const&, int, std::string const&, std::vector<std::string, std::allocator<std::string> > const*, bool, Skin*) (RoRFrameListener.cpp:1161)
==3070==    by 0x562063: RoRFrameListener::updateEvents(float) (RoRFrameListener.cpp:935)
==3070== 
==3070== 157 bytes in 4 blocks are possibly lost in loss record 10,568 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x508C260: char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) (in /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.54.0)
==3070==    by 0x7683D47: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x5CF956: Skidmark::addObject(Ogre::Vector3, std::string) (Skidmark.cpp:175)
==3070==    by 0x5D0328: Skidmark::updatePoint() (Skidmark.cpp:248)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563E920: Ogre::Root::_fireFrameStarted() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563EA28: Ogre::Root::renderOneFrame() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 279 bytes in 9 blocks are possibly lost in loss record 12,201 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x7682395: std::string::_M_mutate(unsigned long, unsigned long, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x56CF799: Ogre::StringUtil::trim(std::string&, bool, bool) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5CE792: SkidmarkManager::processLine(std::vector<std::string, Ogre::STLAllocator<std::string, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >, std::string) (Skidmark.cpp:97)
==3070==    by 0x5CEDC7: SkidmarkManager::loadDefaultModels() (Skidmark.cpp:83)
==3070==    by 0x5CF0FF: SkidmarkManager::SkidmarkManager() (Skidmark.cpp:34)
==3070==    by 0x5D0204: Skidmark::updatePoint() (Singleton.h:45)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 309 bytes in 9 blocks are possibly lost in loss record 12,356 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x7682395: std::string::_M_mutate(unsigned long, unsigned long, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x56CF799: Ogre::StringUtil::trim(std::string&, bool, bool) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5CE7B8: SkidmarkManager::processLine(std::vector<std::string, Ogre::STLAllocator<std::string, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >, std::string) (Skidmark.cpp:99)
==3070==    by 0x5CEDC7: SkidmarkManager::loadDefaultModels() (Skidmark.cpp:83)
==3070==    by 0x5CF0FF: SkidmarkManager::SkidmarkManager() (Skidmark.cpp:34)
==3070==    by 0x5D0204: Skidmark::updatePoint() (Singleton.h:45)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 4,323 bytes in 131 blocks are possibly lost in loss record 15,081 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x508C260: char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) (in /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.54.0)
==3070==    by 0x7683D47: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x5558545: Ogre::Material::Material(Ogre::ResourceManager*, std::string const&, unsigned long long, std::string const&, bool, Ogre::ManualResourceLoader*) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5559545: Ogre::MaterialManager::createImpl(std::string const&, unsigned long long, std::string const&, bool, Ogre::ManualResourceLoader*, std::map<std::string, std::string, std::less<std::string>, Ogre::STLAllocator<std::pair<std::string const, std::string>, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > > const*) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5632CB2: Ogre::ResourceManager::create(std::string const&, std::string const&, bool, Ogre::ManualResourceLoader*, std::map<std::string, std::string, std::less<std::string>, Ogre::STLAllocator<std::pair<std::string const, std::string>, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > > const*) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5CF982: Skidmark::addObject(Ogre::Vector3, std::string) (Skidmark.cpp:175)
==3070==    by 0x5D09C5: Skidmark::updatePoint() (Skidmark.cpp:303)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
@Hiradur

This comment has been minimized.

Show comment
Hide comment
@Hiradur

Hiradur Aug 1, 2015

Contributor
==3070== 5,268 bytes in 131 blocks are possibly lost in loss record 15,131 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x508C260: char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) (in /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.54.0)
==3070==    by 0x7683D47: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x5CF956: Skidmark::addObject(Ogre::Vector3, std::string) (Skidmark.cpp:175)
==3070==    by 0x5D09C5: Skidmark::updatePoint() (Skidmark.cpp:303)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563E920: Ogre::Root::_fireFrameStarted() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563EA28: Ogre::Root::renderOneFrame() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 9,656 bytes in 284 blocks are possibly lost in loss record 15,249 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x7682395: std::string::_M_mutate(unsigned long, unsigned long, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x768293D: std::string::_M_replace_safe(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x5CF23A: SkidmarkManager::getTexture(std::string, std::string, float, std::string&) (basic_string.h:1131)
==3070==    by 0x5D0230: Skidmark::updatePoint() (Skidmark.cpp:238)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563E920: Ogre::Root::_fireFrameStarted() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563EA28: Ogre::Root::renderOneFrame() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 32,700 bytes in 1,090 blocks are possibly lost in loss record 15,384 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x7682395: std::string::_M_mutate(unsigned long, unsigned long, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x768293D: std::string::_M_replace_safe(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x5CFDEA: Skidmark::addObject(Ogre::Vector3, std::string) (basic_string.h:1131)
==3070==    by 0x5D0328: Skidmark::updatePoint() (Skidmark.cpp:248)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563E920: Ogre::Root::_fireFrameStarted() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563EA28: Ogre::Root::renderOneFrame() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 33,536 bytes in 131 blocks are possibly lost in loss record 15,394 of 15,491
==3070==    at 0x4C2CC70: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x187608D0: ??? (in /usr/lib/x86_64-linux-gnu/libdrm_intel.so.1.0.0)
==3070==    by 0x182A3770: ??? (in /usr/lib/x86_64-linux-gnu/dri/i965_dri.so)
==3070==    by 0x182A3B87: ??? (in /usr/lib/x86_64-linux-gnu/dri/i965_dri.so)
==3070==    by 0x18056D88: ??? (in /usr/lib/x86_64-linux-gnu/dri/i965_dri.so)
==3070==    by 0x5554B29: Ogre::ManualObject::end() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5CFE44: Skidmark::addObject(Ogre::Vector3, std::string) (Skidmark.cpp:200)
==3070==    by 0x5D09C5: Skidmark::updatePoint() (Skidmark.cpp:303)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 1,165,170 bytes in 38,839 blocks are possibly lost in loss record 15,476 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x7682395: std::string::_M_mutate(unsigned long, unsigned long, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x768293D: std::string::_M_replace_safe(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x5CFDEA: Skidmark::addObject(Ogre::Vector3, std::string) (basic_string.h:1131)
==3070==    by 0x5D09C5: Skidmark::updatePoint() (Skidmark.cpp:303)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563E920: Ogre::Root::_fireFrameStarted() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563EA28: Ogre::Root::renderOneFrame() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
Contributor

Hiradur commented Aug 1, 2015

==3070== 5,268 bytes in 131 blocks are possibly lost in loss record 15,131 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x508C260: char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) (in /usr/lib/x86_64-linux-gnu/libboost_regex.so.1.54.0)
==3070==    by 0x7683D47: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x5CF956: Skidmark::addObject(Ogre::Vector3, std::string) (Skidmark.cpp:175)
==3070==    by 0x5D09C5: Skidmark::updatePoint() (Skidmark.cpp:303)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563E920: Ogre::Root::_fireFrameStarted() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563EA28: Ogre::Root::renderOneFrame() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 9,656 bytes in 284 blocks are possibly lost in loss record 15,249 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x7682395: std::string::_M_mutate(unsigned long, unsigned long, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x768293D: std::string::_M_replace_safe(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x5CF23A: SkidmarkManager::getTexture(std::string, std::string, float, std::string&) (basic_string.h:1131)
==3070==    by 0x5D0230: Skidmark::updatePoint() (Skidmark.cpp:238)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563E920: Ogre::Root::_fireFrameStarted() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563EA28: Ogre::Root::renderOneFrame() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 32,700 bytes in 1,090 blocks are possibly lost in loss record 15,384 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x7682395: std::string::_M_mutate(unsigned long, unsigned long, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x768293D: std::string::_M_replace_safe(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x5CFDEA: Skidmark::addObject(Ogre::Vector3, std::string) (basic_string.h:1131)
==3070==    by 0x5D0328: Skidmark::updatePoint() (Skidmark.cpp:248)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563E920: Ogre::Root::_fireFrameStarted() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563EA28: Ogre::Root::renderOneFrame() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 33,536 bytes in 131 blocks are possibly lost in loss record 15,394 of 15,491
==3070==    at 0x4C2CC70: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x187608D0: ??? (in /usr/lib/x86_64-linux-gnu/libdrm_intel.so.1.0.0)
==3070==    by 0x182A3770: ??? (in /usr/lib/x86_64-linux-gnu/dri/i965_dri.so)
==3070==    by 0x182A3B87: ??? (in /usr/lib/x86_64-linux-gnu/dri/i965_dri.so)
==3070==    by 0x18056D88: ??? (in /usr/lib/x86_64-linux-gnu/dri/i965_dri.so)
==3070==    by 0x5554B29: Ogre::ManualObject::end() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x5CFE44: Skidmark::addObject(Ogre::Vector3, std::string) (Skidmark.cpp:200)
==3070==    by 0x5D09C5: Skidmark::updatePoint() (Skidmark.cpp:303)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070== 1,165,170 bytes in 38,839 blocks are possibly lost in loss record 15,476 of 15,491
==3070==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3070==    by 0x7682208: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x7682395: std::string::_M_mutate(unsigned long, unsigned long, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x768293D: std::string::_M_replace_safe(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==3070==    by 0x5CFDEA: Skidmark::addObject(Ogre::Vector3, std::string) (basic_string.h:1131)
==3070==    by 0x5D09C5: Skidmark::updatePoint() (Skidmark.cpp:303)
==3070==    by 0x756343: Beam::updateSkidmarks() (Beam.cpp:3042)
==3070==    by 0x742B2A: BeamFactory::updateVisual(float) (BeamFactory.cpp:824)
==3070==    by 0x5645DE: RoRFrameListener::frameStarted(Ogre::FrameEvent const&) (RoRFrameListener.cpp:1377)
==3070==    by 0x563D07B: Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563E920: Ogre::Root::_fireFrameStarted() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
==3070==    by 0x563EA28: Ogre::Root::renderOneFrame() (in /home/hiradur/rigsofrods18/install/lib/libOgreMain.so.1.8.2)
@only-a-ptr

This comment has been minimized.

Show comment
Hide comment
@only-a-ptr

only-a-ptr Aug 2, 2015

Member

@Hiradur I'm not sure I understand the call stacks. It's likely that Skidmark::addObject is leaking, but it's very unlikely that std::string is leaking.

Anyway, I'm starting to suspect this perpetual material generation: https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.cpp#L175 While the manual object is deleted, the material isn't: https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.cpp#L209

Member

only-a-ptr commented Aug 2, 2015

@Hiradur I'm not sure I understand the call stacks. It's likely that Skidmark::addObject is leaking, but it's very unlikely that std::string is leaking.

Anyway, I'm starting to suspect this perpetual material generation: https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.cpp#L175 While the manual object is deleted, the material isn't: https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.cpp#L209

@Hiradur

This comment has been minimized.

Show comment
Hide comment
@Hiradur

Hiradur Aug 2, 2015

Contributor

@only-a-ptr The call stack shows where the memory that is suspected to leak was allocated. At first I thought the leak may not be in std::string but the string parameter of addObject() leaking somehow. Wondering how that could happen I did some more research and I found out that this could be a false positive by Valgrind.

Contributor

Hiradur commented Aug 2, 2015

@only-a-ptr The call stack shows where the memory that is suspected to leak was allocated. At first I thought the leak may not be in std::string but the string parameter of addObject() leaking somehow. Wondering how that could happen I did some more research and I found out that this could be a false positive by Valgrind.

@only-a-ptr

This comment has been minimized.

Show comment
Hide comment
@only-a-ptr

only-a-ptr Aug 3, 2015

Member

@Hiradur @Max98 Please try adding code to delete Ogre::Material allocated here https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.cpp#L175 when the associated Ogre::ManualObject is deleted https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.cpp#L209 and then check if the leaking still occurs.

Member

only-a-ptr commented Aug 3, 2015

@Hiradur @Max98 Please try adding code to delete Ogre::Material allocated here https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.cpp#L175 when the associated Ogre::ManualObject is deleted https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.cpp#L209 and then check if the leaking still occurs.

@Max98 Max98 modified the milestones: RoR 0.4.5.1, RoR 0.4.5 (Nextstable), Post-Nextstable Aug 11, 2015

@Hiradur Hiradur modified the milestones: Post-Nextstable, 0.4.6.0 Oct 24, 2015

@Hiradur

This comment has been minimized.

Show comment
Hide comment
@Hiradur

Hiradur Nov 18, 2015

Contributor

I took another look with a newer version of Valgrind and it doesn't report any memory leaks in skidmarks.cpp. From my testing you have to generate a lot of skidmarks until old ones get deleted so the threshold may just be too high as @only-a-ptr pointed out earlier.
That the FPS don't decrease any further below a certain point also speaks against a memory leak IMO.

The bucket count is 200 where skidmark is instanced (https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/physics/Beam.cpp#L3042 )but the default value is 20 in Skidmark.h. @Max98 Where do these numbers come from?

Anyway, from my testing a value of 20 is good enough and the FPS hit is rather small.

btw:
I also noticed that skid.face is an array of size 2 created here: https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.h#L78
Yet we iterate through 3 elements here: https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.cpp#L168

I'll set the bucket count to 20 and fix the oob problem above. And I'll reduce the view distance for skidmarks, 2km is too much IMO.

Contributor

Hiradur commented Nov 18, 2015

I took another look with a newer version of Valgrind and it doesn't report any memory leaks in skidmarks.cpp. From my testing you have to generate a lot of skidmarks until old ones get deleted so the threshold may just be too high as @only-a-ptr pointed out earlier.
That the FPS don't decrease any further below a certain point also speaks against a memory leak IMO.

The bucket count is 200 where skidmark is instanced (https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/physics/Beam.cpp#L3042 )but the default value is 20 in Skidmark.h. @Max98 Where do these numbers come from?

Anyway, from my testing a value of 20 is good enough and the FPS hit is rather small.

btw:
I also noticed that skid.face is an array of size 2 created here: https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.h#L78
Yet we iterate through 3 elements here: https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gfx/Skidmark.cpp#L168

I'll set the bucket count to 20 and fix the oob problem above. And I'll reduce the view distance for skidmarks, 2km is too much IMO.

@Hiradur Hiradur closed this Nov 18, 2015

@only-a-ptr

This comment has been minimized.

Show comment
Hide comment
@only-a-ptr

only-a-ptr Nov 19, 2015

Member

@Hiradur The skidmark_t::face usage looks like an overflow indeed. Check where it's read from and fix it as you find appropriate.

Member

only-a-ptr commented Nov 19, 2015

@Hiradur The skidmark_t::face usage looks like an overflow indeed. Check where it's read from and fix it as you find appropriate.

@Hiradur

This comment has been minimized.

Show comment
Hide comment
@Hiradur

Hiradur Nov 19, 2015

Contributor

@only-a-ptr Nice catch, I just realized that skid.face isn't used at all. Should I remove it?

Contributor

Hiradur commented Nov 19, 2015

@only-a-ptr Nice catch, I just realized that skid.face isn't used at all. Should I remove it?

@only-a-ptr

This comment has been minimized.

Show comment
Hide comment
@only-a-ptr

only-a-ptr Nov 19, 2015

Member

@Hiradur Absolutely :)

Member

only-a-ptr commented Nov 19, 2015

@Hiradur Absolutely :)

Hiradur added a commit to Hiradur/rigs-of-rods that referenced this issue Nov 19, 2015

[Fix] Huge FPS hit caused by Skidmarks
- reduced bucket count to 20 and view distance to 800m. Fixes RigsOfRods#343

- also fixed OOB access
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment