Forums

Full Version: Memory Leaks
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Playing some VDrift tonight, I noticed that it appears VDrift is leaking memory at quite a rapid pace. To see this, start up a memory monitor and run VDrift with full screen mode off. You will see VDrift initially loads about 100M to get to the first menu. Now visit the Start Game menu, and the memory jumps up a little more due to loading a car. Pick your car and track and start a game. You should see the memory usage jump up another few hundred megabytes or so depending on which track and car you're loading.

As you start driving forward, keep watching the memory usage. For me, it climbed up at a rate around 3 MB per second. Before long the memory is nearly full and the swap starts climbing up...

It is definitely happening while the game is running. When the game is paused, memory usage stops climbing. I can't find anything else which seems to stop or decrease the memory usage.

This is going to take some careful observation of the code. It's very, very slow running VDrift in Valgrind. It took me probably a good 5 minutes to load and 3 minutes to play about 30 seconds in game time. It does work however, just at 0.35 fps. Oddly, I didn't get a lot of printouts while driving, just these when the Practice Game menu loaded (and repeated when the game loaded, probably related to loading a car):

Code:
==10079== Conditional jump or move depends on uninitialised value(s)
==10079==    at 0x44538E: JOEMODEL::ReadData(_IO_FILE*, JOEPACK*, bool) (model.cpp:206)
==10079==    by 0x446328: JOEMODEL::LoadFromHandle(_IO_FILE*, JOEPACK*, bool) (model.cpp:134)
==10079==    by 0x44681C: JOEMODEL::Load(std::string, JOEPACK*, bool) (model.cpp:79)
==10079==    by 0x44E6C0: OBJECTS::AddModel(std::string, std::string, bool, bool, bool, bool, JOEPACK*) (objects.cpp:169)
==10079==    by 0x44ECC8: OBJECTS::Add(VERTEX, float, std::string, std::string, bool, bool, bool, bool, bool, bool, JOEPACK*, float, float, float, float, float, float, SCENENODE*) (objects.cpp:110)
==10079==    by 0x45003C: OBJECTS::LoadObjectsFromFolder(std::string) (objects.cpp:307)
==10079==    by 0x420F73: GAME::LoadWorld() (game.cpp:522)
==10079==    by 0x55856B: VGUI::Gui::ProcessAction(std::string) (gui.cpp:994)
==10079==    by 0x55B2B1: VGUI::Gui::KeyRelease(SDLKey) (gui.cpp:253)
==10079==    by 0x424473: GAME::Start(std::list<std::string, std::allocator<std::string> >&) (game.cpp:1611)
==10079==    by 0x40C1B9: main (main.cpp:26)

==10079== Conditional jump or move depends on uninitialised value(s)
==10079==    at 0x44541C: JOEMODEL::ReadData(_IO_FILE*, JOEPACK*, bool) (model.cpp:211)
==10079==    by 0x446328: JOEMODEL::LoadFromHandle(_IO_FILE*, JOEPACK*, bool) (model.cpp:134)
==10079==    by 0x44681C: JOEMODEL::Load(std::string, JOEPACK*, bool) (model.cpp:79)
==10079==    by 0x44E6C0: OBJECTS::AddModel(std::string, std::string, bool, bool, bool, bool, JOEPACK*) (objects.cpp:169)
==10079==    by 0x44ECC8: OBJECTS::Add(VERTEX, float, std::string, std::string, bool, bool, bool, bool, bool, bool, JOEPACK*, float, float, float, float, float, float, SCENENODE*) (objects.cpp:110)
==10079==    by 0x45003C: OBJECTS::LoadObjectsFromFolder(std::string) (objects.cpp:307)
==10079==    by 0x420F73: GAME::LoadWorld() (game.cpp:522)
==10079==    by 0x55856B: VGUI::Gui::ProcessAction(std::string) (gui.cpp:994)
==10079==    by 0x55B2B1: VGUI::Gui::KeyRelease(SDLKey) (gui.cpp:253)
==10079==    by 0x424473: GAME::Start(std::list<std::string, std::allocator<std::string> >&) (game.cpp:1611)
==10079==    by 0x40C1B9: main (main.cpp:26)

And these as the game loaded:
Code:
==10079== Conditional jump or move depends on uninitialised value(s)
==10079==    at 0x4A26F4: VAMOSWORLD::Update(float, float, _SDL_Joystick**) (vamosworld.cpp:649)
==10079==    by 0x421545: GAME::Update() (game.cpp:230)
==10079==    by 0x42475B: GAME::Start(std::list<std::string, std::allocator<std::string> >&) (game.cpp:1650)
==10079==    by 0x40C1B9: main (main.cpp:26)

==10079== Conditional jump or move depends on uninitialised value(s)
==10079==    at 0x53BE31: Vamos_World::World::update_drift_score(float) (World.cc:756)
==10079==    by 0x4A2966: VAMOSWORLD::Update(float, float, _SDL_Joystick**) (vamosworld.cpp:683)
==10079==    by 0x421545: GAME::Update() (game.cpp:230)
==10079==    by 0x42475B: GAME::Start(std::list<std::string, std::allocator<std::string> >&) (game.cpp:1650)
==10079==    by 0x40C1B9: main (main.cpp:26)


==10079== Thread 2:
==10079== Invalid read of size 2
==10079==    at 0x477402: SOUNDSOURCE::SampleAndAdvanceWithPitch16bit(int*, int*, int) (sound.cpp:1286)
==10079==    by 0x47A67A: SOUND::Callback16bitstereo(void*, unsigned char*, int) (sound.cpp:483)
==10079==    by 0x47A9DD: SOUND_CallbackWrapper(void*, unsigned char*, int) (sound.cpp:375)
==10079==    by 0x4E2F519: (within /usr/lib/libSDL-1.2.so.0.11.0)
==10079==    by 0x4E371B6: (within /usr/lib/libSDL-1.2.so.0.11.0)
==10079==    by 0x4E78FB8: (within /usr/lib/libSDL-1.2.so.0.11.0)
==10079==    by 0x7315316: start_thread (in /lib/libpthread-2.6.1.so)
==10079==    by 0x6528D5C: clone (in /lib/libc-2.6.1.so)
==10079==  Address 0x20BE2348 is 0 bytes after a block of size 209,328 alloc'd
==10079==    at 0x4C220C5: operator new[](unsigned long) (vg_replace_malloc.c:199)
==10079==    by 0x479483: SOUNDBUFFER::LoadWAV(std::string const&, SOUNDINFO const&) (sound.cpp:676)
==10079==    by 0x479BF0: SOUNDBUFFER::Load(std::string const&, SOUNDINFO const&) (sound.cpp:593)
==10079==    by 0x479F58: SOUND::LoadBuffer(std::string const&) (sound.cpp:1499)
==10079==    by 0x47A10B: SOUND::NewSource(std::string const&) (sound.cpp:1475)
==10079==    by 0x51F2DA: Vamos_Body::Gl_Car::engine_sound(std::map<float, std::string, std::less<float>, std::allocator<std::pair<float const, std::string> > >&) (Gl_Car.cc:902)
==10079==    by 0x50435C: Vamos_Body::Car::LoadCarDefinition(std::string, bool, SCENENODE*) (Car.cc:2047)
==10079==    by 0x50CD24: Vamos_Body::Car::read(std::string, std::string, bool, SCENENODE*) (Car.cc:232)
==10079==    by 0x41F5DE: GAME::SelectCar(std::string, bool) (game.cpp:387)
==10079==    by 0x421136: GAME::LoadWorld() (game.cpp:532)
==10079==    by 0x55856B: VGUI::Gui::ProcessAction(std::string) (gui.cpp:994)
==10079==    by 0x55B2B1: VGUI::Gui::KeyRelease(SDLKey) (gui.cpp:253)

==10079== Invalid read of size 2
==10079==    at 0x477426: SOUNDSOURCE::SampleAndAdvanceWithPitch16bit(int*, int*, int) (sound.cpp:1287)
==10079==    by 0x47A67A: SOUND::Callback16bitstereo(void*, unsigned char*, int) (sound.cpp:483)
==10079==    by 0x47A9DD: SOUND_CallbackWrapper(void*, unsigned char*, int) (sound.cpp:375)
==10079==    by 0x4E2F519: (within /usr/lib/libSDL-1.2.so.0.11.0)
==10079==    by 0x4E371B6: (within /usr/lib/libSDL-1.2.so.0.11.0)
==10079==    by 0x4E78FB8: (within /usr/lib/libSDL-1.2.so.0.11.0)
==10079==    by 0x7315316: start_thread (in /lib/libpthread-2.6.1.so)
==10079==    by 0x6528D5C: clone (in /lib/libc-2.6.1.so)
==10079==  Address 0x20BE234A is 2 bytes after a block of size 209,328 alloc'd
==10079==    at 0x4C220C5: operator new[](unsigned long) (vg_replace_malloc.c:199)
==10079==    by 0x479483: SOUNDBUFFER::LoadWAV(std::string const&, SOUNDINFO const&) (sound.cpp:676)
==10079==    by 0x479BF0: SOUNDBUFFER::Load(std::string const&, SOUNDINFO const&) (sound.cpp:593)
==10079==    by 0x479F58: SOUND::LoadBuffer(std::string const&) (sound.cpp:1499)
==10079==    by 0x47A10B: SOUND::NewSource(std::string const&) (sound.cpp:1475)
==10079==    by 0x51F2DA: Vamos_Body::Gl_Car::engine_sound(std::map<float, std::string, std::less<float>, std::allocator<std::pair<float const, std::string> > >&) (Gl_Car.cc:902)
==10079==    by 0x50435C: Vamos_Body::Car::LoadCarDefinition(std::string, bool, SCENENODE*) (Car.cc:2047)
==10079==    by 0x50CD24: Vamos_Body::Car::read(std::string, std::string, bool, SCENENODE*) (Car.cc:232)
==10079==    by 0x41F5DE: GAME::SelectCar(std::string, bool) (game.cpp:387)
==10079==    by 0x421136: GAME::LoadWorld() (game.cpp:532)
==10079==    by 0x55856B: VGUI::Gui::ProcessAction(std::string) (gui.cpp:994)
==10079==    by 0x55B2B1: VGUI::Gui::KeyRelease(SDLKey) (gui.cpp:253)
==10079==

I ran VDrift in Valgrind again in full leak check mode. Here is the leak report, slightly shortened by me (I combined leaks that were the same trace but a different line number of the same file, and removed non-VDrift leaks). I also bolded the important lines.

Quote:==10501== ERROR SUMMARY: 143419 errors from 49 contexts (suppressed: 174 from 1)
==10501== malloc/free: in use at exit: 2,444,277 bytes in 30,868 blocks.
==10501== malloc/free: 4,559,703 allocs, 4,528,835 frees, 1,421,600,120 bytes allocated.
==10501== For counts of detected errors, rerun with: -v
==10501== searching for pointers to 30,868 not-freed blocks.
==10501== checked 8,049,024 bytes.
==10501==

==10501== 40 bytes in 1 blocks are definitely lost in loss record 23 of 138
==10501== at 0x4C21C16: malloc (vg_replace_malloc.c:149)
==10501== by 0x64CD8A1: strdup (in /lib/libc-2.6.1.so)
==10501== by 0x4C2F19: EjgI43220352208034_br_find_exe (binreloc.c:354)
==10501== by 0x46A89C: SETTINGS::SETTINGS() (settings.cpp:87)
==10501== by 0x411E05: GAME::GAME() (game.h:104)
==10501== by 0x40C08C: __static_initialization_and_destruction_0(int, int) (main.cpp:14)
==10501== by 0x40C0B6: _GLOBAL__I_game (main.cpp:38)
==10501== by 0x5A8715: (within /home/thelusiv/code/vdrift/build/vdrift)
==10501== by 0x40A862: _init (in /home/thelusiv/code/vdrift/build/vdrift)
==10501==
==10501==
==10501== 66 bytes in 2 blocks are definitely lost in loss record 30 of 138
==10501== at 0x4C21C16: malloc (vg_replace_malloc.c:149)
==10501== by 0x4C34CD: br_strndup (binreloc.c:722)

==10501== 1,902,148 (5,616 direct, 1,896,532 indirect) bytes in 54 blocks are definitely lost in loss record 32 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x48B58F: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::string const, CONFIGVARIABLE> > >::allocate(unsigned long, void const*) (new_allocator.h:88)
==10501== by 0x48B5B3: std::_Rb_tree<std::string, std::pair<std::string const, CONFIGVARIABLE>, std::_Select1st<std::pair<std::string const, CONFIGVARIABLE> >, std::less<std::string>, std::allocator<std::pair<std::string const, CONFIGVARIABLE> > >::_M_get_node() (stl_tree.h:358)
==10501== by 0x48C1B7: std::_Rb_tree<std::string, std::pair<std::string const, CONFIGVARIABLE>, std::_Select1st<std::pair<std::string const, CONFIGVARIABLE> >, std::less<std::string>, std::allocator<std::pair<std::string const, CONFIGVARIABLE> > >::_M_create_node(std::pair<std::string const, CONFIGVARIABLE> const&) (stl_tree.h:367)
==10501== by 0x4B4E7A: std::_Rb_tree<std::string, std::pair<std::string const, CONFIGVARIABLE>, std::_Select1st<std::pair<std::string const, CONFIGVARIABLE> >, std::less<std::string>, std::allocator<std::pair<std::string const, CONFIGVARIABLE> > >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair<std::string const, CONFIGVARIABLE> const&) (stl_tree.h:819)
==10501== by 0x4B517E: std::_Rb_tree<std::string, std::pair<std::string const, CONFIGVARIABLE>, std::_Select1st<std::pair<std::string const, CONFIGVARIABLE> >, std::less<std::string>, std::allocator<std::pair<std::string const, CONFIGVARIABLE> > >::insert_unique(std::_Rb_tree_iterator<std::pair<std::string const, CONFIGVARIABLE> >, std::pair<std::string const, CONFIGVARIABLE> const&) (stl_tree.h:947)
==10501== by 0x4B5474: std::map<std::string, CONFIGVARIABLE, std::less<std::string>, std::allocator<std::pair<std::string const, CONFIGVARIABLE> > >::insert(std::_Rb_tree_iterator<std::pair<std::string const, CONFIGVARIABLE> >, std::pair<std::string const, CONFIGVARIABLE> const&) (stl_map.h:420)
==10501== by 0x4B554E: std::map<std::string, CONFIGVARIABLE, std::less<std::string>, std::allocator<std::pair<std::string const, CONFIGVARIABLE> > >::operator[](std::string const&) (stl_map.h:348)
==10501== by 0x4B5628: bucketed_hashmap<std::string, CONFIGVARIABLE>::Set(std::string&, CONFIGVARIABLE&) (bucketed_hashmap.h:211)
==10501== by 0x4B056C: CONFIGFILE::Add(std::string&, CONFIGVARIABLE&) (configfile.cpp:194)
==10501== by 0x4B2F4B: CONFIGFILE::ProcessLine(std::string&, std::string) (configfile.cpp:379)
==10501== by 0x4B33B7: CONFIGFILE::Load(std::string) (configfile.cpp:322)
==10501==
==10501==
==10501== 56,964 (504 direct, 56,460 indirect) bytes in 58 blocks are definitely lost in loss record 33 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x54EB7C: __gnu_cxx::new_allocator<VGUI::ControlSet*>::allocate(unsigned long, void const*) (new_allocator.h:88)
==10501== by 0x54EBA4: std::_Vector_base<VGUI::ControlSet*, std::allocator<VGUI::ControlSet*> >::_M_allocate(unsigned long) (stl_vector.h:127)
==10501== by 0x54FB99: std::vector<VGUI::ControlSet*, std::allocator<VGUI::ControlSet*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<VGUI::ControlSet**, std::vector<VGUI::ControlSet*, std::allocator<VGUI::ControlSet*> > >, VGUI::ControlSet* const&) (vector.tcc:275)
==10501== by 0x54FDED: std::vector<VGUI::ControlSet*, std::allocator<VGUI::ControlSet*> >::push_back(VGUI::ControlSet* const&) (stl_vector.h:610)
==10501== by 0x54B3CA: VGUI::ControlGrab::BuildControlVectors() (controlgrab.cpp:266)
==10501== by 0x54FE1C: VGUI::ControlGrab::SetSetting(std::string) (controlgrab.h:89)
==10501== by 0x56BF8C: VGUI::Page::Init() (page.cpp:1203)
==10501== by 0x55E214: VGUI::Page::Page(std::string) (page.h:22)
==10501== by 0x55BDA6: VGUI::Gui::Init() (gui.cpp:48)
==10501== by 0x423FCF: GAME::Start(std::list<std::string, std::allocator<std::string> >&) (game.cpp:1550)
==10501== by 0x40C1B9: main (main.cpp:26)
==10501==
==10501==
==10501== 26,184 (72 direct, 26,112 indirect) bytes in 3 blocks are definitely lost in loss record 37 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x440685: VDrift::LOGGER::AddLog(std::ostream*, unsigned) (logging.cpp:127)
==10501== by 0x46A6DA: SETTINGS::SETTINGS() (settings.cpp:50)
==10501== by 0x411E05: GAME::GAME() (game.h:104)
==10501== by 0x40C08C: __static_initialization_and_destruction_0(int, int) (main.cpp:14)
==10501== by 0x40C0B6: _GLOBAL__I_game (main.cpp:38)
==10501== by 0x5A8715: (within /home/thelusiv/code/vdrift/build/vdrift)
==10501== by 0x40A862: _init (in /home/thelusiv/code/vdrift/build/vdrift)
==10501==
==10501==
==10501== 80 bytes in 2 blocks are definitely lost in loss record 38 of 138
==10501== at 0x4C21C16: malloc (vg_replace_malloc.c:149)
==10501== by 0x4C3354: EjgI43220352208034_br_strcat (binreloc.c:676)
==10501== by 0x4C3429: EjgI43220352208034_br_build_path (binreloc.c:699)
==10501== by 0x4C316A: EjgI43220352208034_br_find_locale_dir (binreloc.c:547)
==10501==
==10501== 84 bytes in 2 blocks are possibly lost in loss record 51 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x5D5C980: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.9)
==10501== by 0x5D5E322: std::string::_M_mutate(unsigned long, unsigned long, unsigned long) (in /usr/lib/libstdc++.so.6.0.9)
==10501== by 0x5D5E926: std::string::erase(unsigned long, unsigned long) (in /usr/lib/libstdc++.so.6.0.9)
==10501== by 0x4B02D4: CONFIGVARIABLE::strLTrim(std::string) (configfile.cpp:283)
==10501== by 0x4B150F: CONFIGVARIABLE::strTrim(std::string) (configfile.cpp:297)

==10501== by 0x4B1976: CONFIGVARIABLE::Set(std::string) (configfile.cpp:223)
==10501== by 0x4B2E2C: CONFIGFILE::ProcessLine(std::string&, std::string) (configfile.cpp:373)
==10501== by 0x4B33B7: CONFIGFILE::Load(std::string) (configfile.cpp:322)
==10501== by 0x564F9D: VGUI::Page::Init() (page.cpp:68)
==10501== by 0x55E214: VGUI::Page::Page(std::string) (page.h:22)
==10501== by 0x55BDA6: VGUI::Gui::Init() (gui.cpp:48)
==10501==
==10501==
==10501== 160 bytes in 2 blocks are definitely lost in loss record 57 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x565593: VGUI::Page::Init() (page.cpp:153)
==10501== by 0x55E214: VGUI::Page::Page(std::string) (page.h:22)
==10501== by 0x55BDA6: VGUI::Gui::Init() (gui.cpp:48)
==10501== by 0x423FCF: GAME::Start(std::list<std::string, std::allocator<std::string> >&) (game.cpp:1550)
==10501== by 0x40C1B9: main (main.cpp:26)
==10501==
==10501==
==10501== 968 (832 direct, 136 indirect) bytes in 2 blocks are definitely lost in loss record 88 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x50B46E: Vamos_Body::Car::LoadCarDefinition(std::string, bool, SCENENODE*) (Car.cc:2704)
==10501== by 0x50CD24: Vamos_Body::Car::read(std::string, std::string, bool, SCENENODE*) (Car.cc:232)
==10501== by 0x57AF1F: VGUI::SpinningCar::LoadCar() (spinning_car.cpp:68)
==10501== by 0x57C252: VGUI::SpinningCar::ResetValue() (spinning_car.cpp:150)
==10501== by 0x562485: VGUI::Page::ClearSettings() (page.cpp:1995)
==10501== by 0x5543F8: VGUI::Gui::ChangePage(std::string) (gui.cpp:1240)
==10501== by 0x559E1A: VGUI::Gui::ProcessAction(std::string) (gui.cpp:1195)
==10501== by 0x55B2B1: VGUI::Gui::KeyRelease(SDLKey) (gui.cpp:253)
==10501== by 0x424473: GAME::Start(std::list<std::string, std::allocator<std::string> >&) (game.cpp:1611)
==10501== by 0x40C1B9: main (main.cpp:26)
==10501==
==10501==
==10501== 1,200 bytes in 50 blocks are definitely lost in loss record 90 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x550F0E: VGUI::Designer::Load() (designer.cpp:92)
==10501== by 0x551D4F: VGUI::Designer::Designer(VGUI::Widget*) (designer.cpp:46)
==10501== by 0x56B1A9: VGUI::Page::Init() (page.cpp:1089)
==10501== by 0x55E214: VGUI::Page::Page(std::string) (page.h:22)
==10501== by 0x55BDA6: VGUI::Gui::Init() (gui.cpp:48)
==10501== by 0x423FCF: GAME::Start(std::list<std::string, std::allocator<std::string> >&) (game.cpp:1550)
==10501== by 0x40C1B9: main (main.cpp:26)
==10501==
==10501==
==10501== 9,533 (896 direct, 8,637 indirect) bytes in 8 blocks are definitely lost in loss record 95 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x54B372: VGUI::ControlGrab::BuildControlVectors() (controlgrab.cpp:266)
==10501== by 0x54FE1C: VGUI::ControlGrab::SetSetting(std::string) (controlgrab.h:89)
==10501== by 0x56BF8C: VGUI::Page::Init() (page.cpp:1203)
==10501==
==10501==
==10501== 3,360 (2,816 direct, 544 indirect) bytes in 8 blocks are definitely lost in loss record 106 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x50BF17: Vamos_Body::Car::LoadCarDefinition(std::string, bool, SCENENODE*) (Car.cc:2757)
==10501== by 0x50CD24: Vamos_Body::Car::read(std::string, std::string, bool, SCENENODE*) (Car.cc:232)
==10501== by 0x57AF1F: VGUI::SpinningCar::LoadCar() (spinning_car.cpp:68)
==10501== by 0x57C252: VGUI::SpinningCar::ResetValue() (spinning_car.cpp:150)
==10501== by 0x562485: VGUI::Page::ClearSettings() (page.cpp:1995)
==10501== by 0x5543F8: VGUI::Gui::ChangePage(std::string) (gui.cpp:1240)
==10501== by 0x559E1A: VGUI::Gui::ProcessAction(std::string) (gui.cpp:1195)
==10501== by 0x55B2B1: VGUI::Gui::KeyRelease(SDLKey) (gui.cpp:253)
==10501== by 0x424473: GAME::Start(std::list<std::string, std::allocator<std::string> >&) (game.cpp:1611)
==10501== by 0x40C1B9: main (main.cpp:26)
==10501==
==10501==
==10501== 3,296 (2,752 direct, 544 indirect) bytes in 8 blocks are definitely lost in loss record 107 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x50C31F: Vamos_Body::Car::LoadCarDefinition(std::string, bool, SCENENODE*) (Car.cc:2781)
==10501== by 0x50CD24: Vamos_Body::Car::read(std::string, std::string, bool, SCENENODE*) (Car.cc:232)
==10501== by 0x57AF1F: VGUI::SpinningCar::LoadCar() (spinning_car.cpp:68)
==10501== by 0x57C252: VGUI::SpinningCar::ResetValue() (spinning_car.cpp:150)
==10501== by 0x562485: VGUI::Page::ClearSettings() (page.cpp:1995)
==10501== by 0x5543F8: VGUI::Gui::ChangePage(std::string) (gui.cpp:1240)
==10501== by 0x559E1A: VGUI::Gui::ProcessAction(std::string) (gui.cpp:1195)
==10501== by 0x55B2B1: VGUI::Gui::KeyRelease(SDLKey) (gui.cpp:253)
==10501== by 0x424473: GAME::Start(std::list<std::string, std::allocator<std::string> >&) (game.cpp:1611)
==10501== by 0x40C1B9: main (main.cpp:26)
==10501==
==10501==
==10501== 4,992 (1,536 direct, 3,456 indirect) bytes in 2 blocks are definitely lost in loss record 114 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x505C37: Vamos_Body::Car::LoadCarDefinition(std::string, bool, SCENENODE*) (Car.cc:2237)
==10501==
==10501==
==10501== 2,496 (768 direct, 1,728 indirect) bytes in 1 blocks are definitely lost in loss record 115 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x506D12: Vamos_Body::Car::LoadCarDefinition(std::string, bool, SCENENODE*) (Car.cc:2331)
==10501==
==10501==
==10501== 920 (784 direct, 136 indirect) bytes in 2 blocks are definitely lost in loss record 116 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x50AE5B: Vamos_Body::Car::LoadCarDefinition(std::string, bool, SCENENODE*) (Car.cc:2675)
==10501== by 0x50CD24: Vamos_Body::Car::read(std::string, std::string, bool, SCENENODE*) (Car.cc:232)
==10501== by 0x41F5DE: GAME::SelectCar(std::string, bool) (game.cpp:387)
==10501== by 0x421136: GAME::LoadWorld() (game.cpp:532)
==10501== by 0x55856B: VGUI::Gui::ProcessAction(std::string) (gui.cpp:994)
==10501== by 0x55B2B1: VGUI::Gui::KeyRelease(SDLKey) (gui.cpp:253)
==10501== by 0x424473: GAME::Start(std::list<std::string, std::allocator<std::string> >&) (game.cpp:1611)
==10501== by 0x40C1B9: main (main.cpp:26)
==10501==
==10501==
==10501== 824 (688 direct, 136 indirect) bytes in 2 blocks are definitely lost in loss record 117 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x50C6ED: Vamos_Body::Car::LoadCarDefinition(std::string, bool, SCENENODE*) (Car.cc:2802)
==10501==
==10501==
==10501== 968 (832 direct, 136 indirect) bytes in 2 blocks are definitely lost in loss record 120 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x50BB50: Vamos_Body::Car::LoadCarDefinition(std::string, bool, SCENENODE*) (Car.cc:2736)
==10501==
==10501==
==10501== 2,496 (768 direct, 1,728 indirect) bytes in 1 blocks are definitely lost in loss record 123 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x5069FA: Vamos_Body::Car::LoadCarDefinition(std::string, bool, SCENENODE*) (Car.cc:2311)
==10501==
==10501==
==10501== 242,167 (10,208 direct, 231,959 indirect) bytes in 58 blocks are definitely lost in loss record 129 of 138
==10501== at 0x4C22425: operator new(unsigned long) (vg_replace_malloc.c:167)
==10501== by 0x55BD8C: VGUI::Gui::Init() (gui.cpp:48)
==10501==
==10501== LEAK SUMMARY:
==10501== definitely lost: 31,324 bytes in 270 blocks.
==10501== indirectly lost: 2,228,484 bytes in 26,813 blocks.
==10501== possibly lost: 58,724 bytes in 820 blocks.
==10501== still reachable: 125,745 bytes in 2,965 blocks.
==10501== suppressed: 0 bytes in 0 blocks.
==10501== Reachable blocks (those to which a pointer was found) are not shown.
==10501== To see them, rerun with: --leak-check=full --show-reachable=yes

The annoying thing about all that is that all the leaks it finds are in the loading process, and not during the game play. Perhaps it has something to do with the game running at a far reduced framerate that keeps the memory usage from going up as it does at normal speed.

Any ideas?
Should be fixed in R1948. The problem was that when I was trying different techniques to speed up collision detection, one of the approaches I tried involved caching all of the physics collisions. I moved away from that approach and so I stopped checking and clearing the cache, but didn't stop adding things to the cache. Whoops!

By the way, while trying different ideas to troubleshoot this bug I tried using bullet 2.66 (instead of 2.64) and had no issues (except the leak was still there, because of the above noted problem)... I don't know that there are any big advantages, but we might as well upgrade the included bullet to 2.66. Any objections?
Not sure what else you did, but it totally screwed the pooch. CO on Estoril - the best I can describe is if you drive off the road, the car turns over, and you end up driving on the map...upside down. At one point, even had the car driving around upside down with the track right side up. Something's horked. Let me know if you want a screen shot.
joevenzon Wrote:Should be fixed in R1948.

the memory leak might be gone, but so is the collision detection and everything else. on top of that, the car seems to start some way off the ground on most tracks (paul ricard seems to be the one exception). i've reverted back to r1947 for now.

--alex--
Oops. :-) I forgot to turn the car body collision back on, and I had an invisible collision plane still active. It's fixed in R1950.
joevenzon Wrote:It's fixed in R1950.

indeed, everything seems to be working again. thanks.

--alex--
1950 looks good so far.
As far as I can tell, the major memory leakage I was seeing before is now gone. Great work!