The following warnings occurred:
Warning [2] Undefined array key "lockoutexpiry" - Line: 94 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 94 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "lockoutexpiry" - Line: 573 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 573 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $can_access_moderationqueue - Line: 752 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 752 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 892 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 892 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 892 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 892 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $awaitingusers - Line: 34 - File: global.php(959) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/global.php(959) : eval()'d code 34 errorHandler->error
/global.php 959 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 1024 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 1024 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5308 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 5308 errorHandler->error
/global.php 1024 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key 1 - Line: 1474 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1474 errorHandler->error
/inc/functions.php 1429 fetch_forum_permissions
/printthread.php 76 forum_permissions
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Forums
Memory leaks in car loading function - Printable Version

+- Forums (https://www.vdrift.net/Forum)
+-- Forum: Community (https://www.vdrift.net/Forum/forumdisplay.php?fid=3)
+--- Forum: Bugs (https://www.vdrift.net/Forum/forumdisplay.php?fid=7)
+--- Thread: Memory leaks in car loading function (/showthread.php?tid=165)



Memory leaks in car loading function - thelusiv - 12-08-2005

I got the gui set up to load and unload cars in the practice game menu as the user switches cars. I made sure to delete my car Gl_Car object when switching, but still my system memory usage goes up somewhere between 1 and 10 MB every time I switch. Switching cars 5 or 6 times results in about 100 MB of lost memory. This could be an issue on machines with low amounts of free memory (like anything running Windows XP on 256 MB or less of RAM...). I ran Valgrind to try to get a better idea of why this was happening. Below is the important output (I chopped out a bunch of stuff about leaks in OpenAL). I ran it on the menus-v2 branch (notice there are no memory leaks in the VGUI namespace! Wink ) with the command:


valgrind --suppressions=tools/valgrind/vdrift.supp --leak-check=full

First there are these two errors it reported while the program was running:

==19323==
==19323== Use of uninitialised value of size 4
==19323== at 0x80B234C: Vamos_Body::Car::LoadCarDefinition(std:Confusedtring) (Three_Vector.h:47)
==19323== by 0x80A4CB6: Vamos_Body::Car::read(std:Confusedtring, std:Confusedtring) (basic_string.h:888)
==19323== by 0x810BDC6: VGUI::SpinningCar::LoadCar() (basic_string.h:888)
==19323== by 0x810C9B9: VGUI::SpinningCar::ResetValue() (spinning_car.cpp:122)
==19323== by 0x80FF2A2: VGUI:Tongueage::ClearSettings() (stl_vector.h:501)
==19323== by 0x810667A: VGUI::Gui::ChangePage(std:Confusedtring) (stl_map.h:312)
==19323== by 0x81063BF: VGUI::Gui:TonguerocessAction(std:Confusedtring) (gui.cpp:2102)
==19323== by 0x81040A3: VGUI::Gui::MouseRelease() (gui.cpp:1866)
==19323== by 0x805511B: main (main.cpp:2292)
==19323==

==19323==
==19323== Use of uninitialised value of size 4
==19323== at 0x80C6BAE: Vamos_Body::Gl_Car::draw(bool, float) (Gl_Car.cc:473)
==19323== by 0x810CD45: VGUI::SpinningCar:Big Grinraw(float) (spinning_car.cpp:211)
==19323== by 0x80FD55D: VGUI:Tongueage:Big Grinraw(float) (stl_vector.h:501)
==19323== by 0x8102520: VGUI::Gui:Big Grinraw() (stl_map.h:312)
==19323== by 0x80543A5: drawGLScene() (main.cpp:1904)
==19323== by 0x8054FC6: main (main.cpp:2329)
==19323==

And then there are the leaks, which are reported after the program ends:

==19323==
==19323== ERROR SUMMARY: 3449 errors from 12 contexts (suppressed: 1559310 from 15)
==19323== malloc/free: in use at exit: 865631 bytes in 6230 blocks.
==19323== malloc/free: 1383961 allocs, 1377731 frees, 150140049 bytes allocated.
==19323== For counts of detected errors, rerun with: -v
==19323== searching for pointers to 6230 not-freed blocks.
==19323== checked 9085676 bytes.
==19323==
==19323==
==19323== 440 (380 direct, 60 indirect) bytes in 1 blocks are definitely lost in loss record 69 of 166
==19323== at 0x1B9034D8: operator new(unsigned) (in /usr/lib/valgrind/vgpreload_memcheck.so)
==19323== by 0x80B5467: Vamos_Body::Car::LoadCarDefinition(std:Confusedtring) (stl_vector.h:596)
==19323== by 0x80A4CB6: Vamos_Body::Car::read(std:Confusedtring, std:Confusedtring) (basic_string.h:888)
==19323== by 0x810BDC6: VGUI::SpinningCar::LoadCar() (basic_string.h:888)
==19323== by 0x810C9B9: VGUI::SpinningCar::ResetValue() (spinning_car.cpp:122)
==19323== by 0x80FF2A2: VGUI:Tongueage::ClearSettings() (stl_vector.h:501)
==19323== by 0x810667A: VGUI::Gui::ChangePage(std:Confusedtring) (stl_map.h:312)
==19323== by 0x81063BF: VGUI::Gui:TonguerocessAction(std:Confusedtring) (gui.cpp:2102)
==19323== by 0x81040A3: VGUI::Gui::MouseRelease() (gui.cpp:1866)
==19323== by 0x805511B: main (main.cpp:2292)
==19323==
==19323==
==19323== 392 (332 direct, 60 indirect) bytes in 1 blocks are definitely lost in loss record 71 of 166
==19323== at 0x1B9034D8: operator new(unsigned) (in /usr/lib/valgrind/vgpreload_memcheck.so)
==19323== by 0x80B6112: Vamos_Body::Car::LoadCarDefinition(std:Confusedtring) (stl_vector.h:596)
==19323== by 0x80A4CB6: Vamos_Body::Car::read(std:Confusedtring, std:Confusedtring) (basic_string.h:888)
==19323== by 0x810BDC6: VGUI::SpinningCar::LoadCar() (basic_string.h:888)
==19323== by 0x810C9B9: VGUI::SpinningCar::ResetValue() (spinning_car.cpp:122)
==19323== by 0x80FF2A2: VGUI:Tongueage::ClearSettings() (stl_vector.h:501)
==19323== by 0x810667A: VGUI::Gui::ChangePage(std:Confusedtring) (stl_map.h:312)
==19323== by 0x81063BF: VGUI::Gui:TonguerocessAction(std:Confusedtring) (gui.cpp:2102)
==19323== by 0x81040A3: VGUI::Gui::MouseRelease() (gui.cpp:1866)
==19323== by 0x805511B: main (main.cpp:2292)
==19323==
==19323==
==19323== 464 (404 direct, 60 indirect) bytes in 1 blocks are definitely lost in loss record 74 of 166
==19323== at 0x1B9034D8: operator new(unsigned) (in /usr/lib/valgrind/vgpreload_memcheck.so)
==19323== by 0x80B5AC2: Vamos_Body::Car::LoadCarDefinition(std:Confusedtring) (stl_vector.h:596)
==19323== by 0x80A4CB6: Vamos_Body::Car::read(std:Confusedtring, std:Confusedtring) (basic_string.h:888)
==19323== by 0x810BDC6: VGUI::SpinningCar::LoadCar() (basic_string.h:888)
==19323== by 0x810C9B9: VGUI::SpinningCar::ResetValue() (spinning_car.cpp:122)
==19323== by 0x80FF2A2: VGUI:Tongueage::ClearSettings() (stl_vector.h:501)
==19323== by 0x810667A: VGUI::Gui::ChangePage(std:Confusedtring) (stl_map.h:312)
==19323== by 0x81063BF: VGUI::Gui:TonguerocessAction(std:Confusedtring) (gui.cpp:2102)
==19323== by 0x81040A3: VGUI::Gui::MouseRelease() (gui.cpp:1866)
==19323== by 0x805511B: main (main.cpp:2292)
==19323==
==19323==
==19323== 1176 (996 direct, 180 indirect) bytes in 3 blocks are definitely lost in loss record 87 of 166
==19323== at 0x1B9034D8: operator new(unsigned) (in /usr/lib/valgrind/vgpreload_memcheck.so)
==19323== by 0x80B5EEA: Vamos_Body::Car::LoadCarDefinition(std:Confusedtring) (stl_vector.h:596)
==19323== by 0x80A4CB6: Vamos_Body::Car::read(std:Confusedtring, std:Confusedtring) (basic_string.h:888)
==19323== by 0x810BDC6: VGUI::SpinningCar::LoadCar() (basic_string.h:888)
==19323== by 0x810C9B9: VGUI::SpinningCar::ResetValue() (spinning_car.cpp:122)
==19323== by 0x80FF2A2: VGUI:Tongueage::ClearSettings() (stl_vector.h:501)
==19323== by 0x810667A: VGUI::Gui::ChangePage(std:Confusedtring) (stl_map.h:312)
==19323== by 0x81063BF: VGUI::Gui:TonguerocessAction(std:Confusedtring) (gui.cpp:2102)
==19323== by 0x81040A3: VGUI::Gui::MouseRelease() (gui.cpp:1866)
==19323== by 0x805511B: main (main.cpp:2292)
==19323==
==19323==
==19323== 1188 (1008 direct, 180 indirect) bytes in 3 blocks are definitely lost in loss record 90 of 166
==19323== at 0x1B9034D8: operator new(unsigned) (in /usr/lib/valgrind/vgpreload_memcheck.so)
==19323== by 0x80B5C69: Vamos_Body::Car::LoadCarDefinition(std:Confusedtring) (stl_vector.h:596)
==19323== by 0x80A4CB6: Vamos_Body::Car::read(std:Confusedtring, std:Confusedtring) (basic_string.h:888)
==19323== by 0x810BDC6: VGUI::SpinningCar::LoadCar() (basic_string.h:888)
==19323== by 0x810C9B9: VGUI::SpinningCar::ResetValue() (spinning_car.cpp:122)
==19323== by 0x80FF2A2: VGUI:Tongueage::ClearSettings() (stl_vector.h:501)
==19323== by 0x810667A: VGUI::Gui::ChangePage(std:Confusedtring) (stl_map.h:312)
==19323== by 0x81063BF: VGUI::Gui:TonguerocessAction(std:Confusedtring) (gui.cpp:2102)
==19323== by 0x81040A3: VGUI::Gui::MouseRelease() (gui.cpp:1866)
==19323== by 0x805511B: main (main.cpp:2292)
==19323==
==19323==
==19323== 46304 (1448 direct, 44856 indirect) bytes in 1 blocks are definitely lost in loss record 97 of 166
==19323== at 0x1B9034D8: operator new(unsigned) (in /usr/lib/valgrind/vgpreload_memcheck.so)
==19323== by 0x80B446A: Vamos_Body::Car::LoadCarDefinition(std:Confusedtring) (Car.cc:2246)
==19323== by 0x80A4CB6: Vamos_Body::Car::read(std:Confusedtring, std:Confusedtring) (basic_string.h:888)
==19323== by 0x810BDC6: VGUI::SpinningCar::LoadCar() (basic_string.h:888)
==19323== by 0x810C9B9: VGUI::SpinningCar::ResetValue() (spinning_car.cpp:122)
==19323== by 0x80FF2A2: VGUI:Tongueage::ClearSettings() (stl_vector.h:501)
==19323== by 0x810667A: VGUI::Gui::ChangePage(std:Confusedtring) (stl_map.h:312)
==19323== by 0x81063BF: VGUI::Gui:TonguerocessAction(std:Confusedtring) (gui.cpp:2102)
==19323== by 0x81040A3: VGUI::Gui::MouseRelease() (gui.cpp:1866)
==19323== by 0x805511B: main (main.cpp:2292)
==19323==
==19323==
==19323== 46700 (1448 direct, 45252 indirect) bytes in 1 blocks are definitely lost in loss record 109 of 166
==19323== at 0x1B9034D8: operator new(unsigned) (in /usr/lib/valgrind/vgpreload_memcheck.so)
==19323== by 0x80B4982: Vamos_Body::Car::LoadCarDefinition(std:Confusedtring) (Car.cc:2274)
==19323== by 0x80A4CB6: Vamos_Body::Car::read(std:Confusedtring, std:Confusedtring) (basic_string.h:888)
==19323== by 0x810BDC6: VGUI::SpinningCar::LoadCar() (basic_string.h:888)
==19323== by 0x810C9B9: VGUI::SpinningCar::ResetValue() (spinning_car.cpp:122)
==19323== by 0x80FF2A2: VGUI:Tongueage::ClearSettings() (stl_vector.h:501)
==19323== by 0x810667A: VGUI::Gui::ChangePage(std:Confusedtring) (stl_map.h:312)
==19323== by 0x81063BF: VGUI::Gui:TonguerocessAction(std:Confusedtring) (gui.cpp:2102)
==19323== by 0x81040A3: VGUI::Gui::MouseRelease() (gui.cpp:1866)
==19323== by 0x805511B: main (main.cpp:2292)
==19323==
==19323==
==19323== 44384 (1448 direct, 42936 indirect) bytes in 1 blocks are definitely lost in loss record 110 of 166
==19323== at 0x1B9034D8: operator new(unsigned) (in /usr/lib/valgrind/vgpreload_memcheck.so)
==19323== by 0x80B4E97: Vamos_Body::Car::LoadCarDefinition(std:Confusedtring) (Car.cc:2302)
==19323== by 0x80A4CB6: Vamos_Body::Car::read(std:Confusedtring, std:Confusedtring) (basic_string.h:888)
==19323== by 0x810BDC6: VGUI::SpinningCar::LoadCar() (basic_string.h:888)
==19323== by 0x810C9B9: VGUI::SpinningCar::ResetValue() (spinning_car.cpp:122)
==19323== by 0x80FF2A2: VGUI:Tongueage::ClearSettings() (stl_vector.h:501)
==19323== by 0x810667A: VGUI::Gui::ChangePage(std:Confusedtring) (stl_map.h:312)
==19323== by 0x81063BF: VGUI::Gui:TonguerocessAction(std:Confusedtring) (gui.cpp:2102)
==19323== by 0x81040A3: VGUI::Gui::MouseRelease() (gui.cpp:1866)
==19323== by 0x805511B: main (main.cpp:2292)
==19323==
==19323==
==19323== 336 bytes in 1 blocks are possibly lost in loss record 124 of 166
==19323== at 0x1B9034D8: operator new(unsigned) (in /usr/lib/valgrind/vgpreload_memcheck.so)
==19323== by 0x80B5C69: Vamos_Body::Car::LoadCarDefinition(std:Confusedtring) (stl_vector.h:596)
==19323== by 0x80A4CB6: Vamos_Body::Car::read(std:Confusedtring, std:Confusedtring) (basic_string.h:888)
==19323== by 0x810BDC6: VGUI::SpinningCar::LoadCar() (basic_string.h:888)
==19323== by 0x810C9B9: VGUI::SpinningCar::ResetValue() (spinning_car.cpp:122)
==19323== by 0x80FF2A2: VGUI:Tongueage::ClearSettings() (stl_vector.h:501)
==19323== by 0x810667A: VGUI::Gui::ChangePage(std:Confusedtring) (stl_map.h:312)
==19323== by 0x81063BF: VGUI::Gui:TonguerocessAction(std:Confusedtring) (gui.cpp:2102)
==19323== by 0x81040A3: VGUI::Gui::MouseRelease() (gui.cpp:1866)
==19323== by 0x805511B: main (main.cpp:2292)
==19323==
==19323==
==19323== 416 (356 direct, 60 indirect) bytes in 1 blocks are definitely lost in loss record 128 of 166
==19323== at 0x1B9034D8: operator new(unsigned) (in /usr/lib/valgrind/vgpreload_memcheck.so)
==19323== by 0x80B1E7E: Vamos_Body::Car::LoadCarDefinition(std:Confusedtring) (Car.cc:1861)
==19323== by 0x80A4CB6: Vamos_Body::Car::read(std:Confusedtring, std:Confusedtring) (basic_string.h:888)
==19323== by 0x810BDC6: VGUI::SpinningCar::LoadCar() (basic_string.h:888)
==19323== by 0x810C9B9: VGUI::SpinningCar::ResetValue() (spinning_car.cpp:122)
==19323== by 0x80FF2A2: VGUI:Tongueage::ClearSettings() (stl_vector.h:501)
==19323== by 0x810667A: VGUI::Gui::ChangePage(std:Confusedtring) (stl_map.h:312)
==19323== by 0x81063BF: VGUI::Gui:TonguerocessAction(std:Confusedtring) (gui.cpp:2102)
==19323== by 0x81040A3: VGUI::Gui::MouseRelease() (gui.cpp:1866)
==19323== by 0x805511B: main (main.cpp:2292)
==19323==
==19323==
==19323== 43920 (1448 direct, 42472 indirect) bytes in 1 blocks are definitely lost in loss record 157 of 166
==19323== at 0x1B9034D8: operator new(unsigned) (in /usr/lib/valgrind/vgpreload_memcheck.so)
==19323== by 0x80B3F4F: Vamos_Body::Car::LoadCarDefinition(std:Confusedtring) (Car.cc:2217)
==19323== by 0x80A4CB6: Vamos_Body::Car::read(std:Confusedtring, std:Confusedtring) (basic_string.h:888)
==19323== by 0x810BDC6: VGUI::SpinningCar::LoadCar() (basic_string.h:888)
==19323== by 0x810C9B9: VGUI::SpinningCar::ResetValue() (spinning_car.cpp:122)
==19323== by 0x80FF2A2: VGUI:Tongueage::ClearSettings() (stl_vector.h:501)
==19323== by 0x810667A: VGUI::Gui::ChangePage(std:Confusedtring) (stl_map.h:312)
==19323== by 0x81063BF: VGUI::Gui:TonguerocessAction(std:Confusedtring) (gui.cpp:2102)
==19323== by 0x81040A3: VGUI::Gui::MouseRelease() (gui.cpp:1866)
==19323== by 0x805511B: main (main.cpp:2292)
==19323==
==19323==
==19323== 145768 bytes in 27 blocks are possibly lost in loss record 166 of 166
==19323== at 0x1B9034D8: operator new(unsigned) (in /usr/lib/valgrind/vgpreload_memcheck.so)
==19323== by 0x1BBE98CA: std::__default_alloc_template<true, 0>::_S_chunk_alloc(unsigned, int&ampWink (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libstdc++.so.5.0.7)
==19323== by 0x1BBE97DC: std::__default_alloc_template<true, 0>::_S_refill(unsigned) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libstdc++.so.5.0.7)
==19323== by 0x1BBE94D7: std::__default_alloc_template<true, 0>::allocate(unsigned) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libstdc++.so.5.0.7)
==19323== by 0x1BBEEE67: std:Confusedtring::_Rep::_S_create(unsigned, std::allocator<char> const&ampWink (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libstdc++.so.5.0.7)
==19323== by 0x1BBEEF3D: std:Confusedtring::_Rep::_M_clone(std::allocator<char> const&, unsigned) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libstdc++.so.5.0.7)
==19323== by 0x1BBECB5C: std:Confusedtring::reserve(unsigned) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libstdc++.so.5.0.7)
==19323== by 0x1BBECEC3: std:Confusedtring::append(std:Confusedtring const&ampWink (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libstdc++.so.5.0.7)
==19323== by 0x805654C: std::basic_string<char, std::char_traits<char>, std::allocator<char> > std::operator+<char, std::char_traits<char>, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&ampWink (basic_string.h:871)
==19323== by 0x8079BF5: SETTINGS::Init() (basic_string.h:888)
==19323== by 0x80764CE: SETTINGS::SETTINGS() (settings.cpp:43)
==19323== by 0x8055EC7: __static_initialization_and_destruction_0(int, int) (main.cpp:136)
==19323==
==19323== LEAK SUMMARY:
==19323== definitely lost: 9825 bytes in 19 blocks.
==19323== indirectly lost: 180464 bytes in 117 blocks.
==19323== possibly lost: 167576 bytes in 674 blocks.
==19323== still reachable: 507766 bytes in 5420 blocks.
==19323== suppressed: 0 bytes in 0 blocks.
==19323== Reachable blocks (those to which a pointer was found) are not shown.
==19323== To see them, rerun with: --show-reachable=yes


Memory leaks in car loading function - joevenzon - 12-08-2005

this should be mostly fixed in the menus svn branchnot sure where the stl vector errors are coming from, or where the settings problems are.. but i'll let you fix the settings class. :-)


Memory leaks in car loading function - thelusiv - 12-09-2005

Yeah, I've been hacking on settings. I finally am able to clean it up, but there's still something in the init that valgrind isn't happy about. I'll keep poking around.The car loading stuff is all better though, there's no memory leaking there anymore as far as I can tell.