Skip to content
This repository has been archived by the owner on Apr 17, 2022. It is now read-only.

memory leaks in 3.1_beta4 #3218

Closed
wzdev-ci opened this issue Feb 25, 2012 · 23 comments
Closed

memory leaks in 3.1_beta4 #3218

wzdev-ci opened this issue Feb 25, 2012 · 23 comments

Comments

@wzdev-ci
Copy link
Contributor

keyword_memory_leak_valgrind resolution_duplicate type_bug | by neofutur


on a small map , MP 4p game, warzone2100 is reaching more than 1200 MB RAM usage, is this normal ?

top information after the end of a 4p MP game :

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8523 neofutur 20 0 1158m 277m 3236 D 1 56.9 56:59.24 warzone2100

in my case its swapping , but i can end the game, but when the game ends wz have a problem to free RAM and swap
10 mins after the end of the game its still using 1200 mb memory
I have to kill -9 everytime I end a game or memory will never be freed
kill -9 frees it immediately
its beta4 built with nodebug ( had same problem before building with nodebug and launched with ./warzone2100 --nosound --noshadows --window --resolution=800x600, with 128 for textures
I waited up to 30 mins to see if it finally frees the memory, but no it will never free it
a strange thing is that an strace -p 8523 ( wz2100 process number ) shows nothing, the process does nothing at this time when it should free the memory
trying to use valgrind to find memory leaks :

valgrind --tool=memcheck  ./warzone2100 --nosound --noshadows --window --resolution=800x600

i found many ones like :

==8523##  Address 0xb7152980 is not stack'd, malloc'd or (recently) free'd8523== Invalid write of size 1


Issue migrated from trac:3218 at 2022-04-16 08:58:09 -0700

@wzdev-ci
Copy link
Contributor Author

neofutur uploaded file valgrind_memleak_wz2100.txt (11.3 KiB)

valgrind find memleaks

@wzdev-ci
Copy link
Contributor Author

vexed commented


Well, looking at the valgrind log it shows

164	==2131== HEAP SUMMARY:
165	==2131==     in use at exit: 229,297 bytes in 4,380 blocks
166	==2131==   total heap usage: 404,372 allocs, 399,992 frees, 224,080,530 bytes allocated
167	==2131## 1682131== LEAK SUMMARY:
169	==2131==    definitely lost: 1,156 bytes in 25 blocks
170	==2131==    indirectly lost: 3,044 bytes in 57 blocks
171	==2131==      possibly lost: 83,739 bytes in 1,881 blocks
172	==2131==    still reachable: 141,358 bytes in 2,417 blocks

Yeah, we have some leaks, but, no where near 1.2GBs, so I assume the issue is most likely with your video drivers.
What hardware do you got ?

@wzdev-ci
Copy link
Contributor Author

Safety0ff changed _comment0 which not transferred by tractive

@wzdev-ci
Copy link
Contributor Author

neofutur commented


Yeah, we have some leaks, but, no where near 1.2GBs, so I assume the issue is most likely with your video drivers.

this valgrind file is just an small example, running wz2100 2 minutes, and not even creating a game !

try it with a complete session, creating a game and playing it 1 hour, you ll find 1 GB leak

my computer is not powerful enough to run a complete valgrind session, including playing a real game, so I just attached a small file, 2 minutes valgrind debug.

What hardware do you got ?

 lenovo T60
     neofutur@t60:~$ lspci
00:00.0 Host bridge: Intel Corporation Mobile 945GM/PM/GMS, 943/940GML and 945GT Express Memory Controller Hub (rev 03)
00:02.0 VGA compatible controller: Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller (rev 03)
00:02.1 Display controller: Intel Corporation Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller (rev 03)
00:1b.0 Audio device: Intel Corporation N10/ICH 7 Family High Definition Audio Controller (rev 02)
00:1c.0 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 1 (rev 02)
00:1c.1 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 2 (rev 02)
00:1c.2 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 3 (rev 02)
00:1c.3 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 4 (rev 02)
00:1d.0 USB Controller: Intel Corporation N10/ICH7 Family USB UHCI Controller #1 (rev 02)
00:1d.1 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #2 (rev 02)
00:1d.2 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #3 (rev 02)
00:1d.3 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #4 (rev 02)
00:1d.7 USB Controller: Intel Corporation N10/ICH 7 Family USB2 EHCI Controller (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev e2)
00:1f.0 ISA bridge: Intel Corporation 82801GBM (ICH7-M) LPC Interface Bridge (rev 02)
00:1f.2 IDE interface: Intel Corporation 82801GBM/GHM (ICH7 Family) SATA IDE Controller (rev 02)
00:1f.3 SMBus: Intel Corporation N10/ICH 7 Family SMBus Controller (rev 02)
02:00.0 Ethernet controller: Intel Corporation 82573L Gigabit Ethernet Controller
03:00.0 Ethernet controller: Atheros Communications Inc. AR5212 802.11abg NIC (rev 01)
15:00.0 CardBus bridge: Texas Instruments PCI1510 PC card Cardbus Controller

@wzdev-ci
Copy link
Contributor Author

cybersphinx changed status from new to closed

@wzdev-ci
Copy link
Contributor Author

cybersphinx changed resolution from `` to external

@wzdev-ci
Copy link
Contributor Author

cybersphinx commented


Can't reproduce this. I did a little plot here (possibly not exact, but if anything it's exaggerated), and memory usage of Warzone and all its libraries didn't increase by that much during an hour long autogame. The jump at the beginning is where it loads textures, then it gradually increases, but not by alarming amounts. The jumps at the end come from some saving and loading.

Probably a problem of the drivers/libraries Warzone uses, not the game directly.

@wzdev-ci
Copy link
Contributor Author

cybersphinx uploaded file wz-memory.png (8.4 KiB)

wz-memory.png

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Apr 5, 2012

crass changed status from closed to reopened

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Apr 5, 2012

crass changed resolution from external to ``

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Apr 5, 2012

crass commented


I have verified that it uses a ton of memory after playing for awhile the ram usage goes through the roof!

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Apr 8, 2012

T_X commented


Could you rerun valgrind with "--leak-check=full"? That should help finding out whether and which memory leaks are warzone2100's fault and which ones are buggy/outdated libraries or drivers. But I agree with vexed, even if they were all Warzone's fault, they do not add up to 1.2GB.

@crass: A valgrind output or at least a graph like cybersphinx created would be helpful.

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Apr 8, 2012

cybersphinx commented


Made another graph of a netgame (4 nexus AIs autogame on rush), with

watch "(ps axu|grep warzone|grep -v grep)|awk '{print \$5 + \$6}'|tr '\n' ' '|awk '{print \$1 + \$2 + \$3 + \$4}'|parallel echo \$\(date +%s\)|tee -a memuse"

and then

plot "memuse" using (($1-[first value in memuse])/60):($2/1024) with lines

in gnuplot. Still no abnormal increase in memory usage. The graph is not very useful though, unless you can correlate memory usage with in-game events.

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Apr 8, 2012

cybersphinx uploaded file autogame-mem.png (8.3 KiB)

autogame-mem.png

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Apr 8, 2012

vexed changed priority from normal to major

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Apr 8, 2012

vexed changed operating_system which not transferred by tractive

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Apr 8, 2012

vexed changed milestone from unspecified to 3.1

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Apr 8, 2012

vexed commented


Hmm, after hooking the allocators and doing stack dumps on each allocation, I can confirm that we are using gobs of memory and if you play long enough, it will hit the pagefile while it swaps out the memory blocks.

Lots of these are caused by the new NET* routines that don't cleanup after themselves.
Adding some destructors does indeed help, but that don't clean up everything because of the way it was written.

Already have eliminated lots of leaks, from the effects to the UTF command line conversion, to (most of) the view data, but the NET* ones are still a issue.

@wzdev-ci
Copy link
Contributor Author

vexed commented


Patches are being done in #3395

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Jun 9, 2012

Safety0ff commented


Replying to Warzone2100/old-trac-import#3218 (comment:6):

in gnuplot. Still no abnormal increase in memory usage. The graph is not very useful though, unless you can correlate memory usage with in-game events.
You could try using valgrind --tool=massif: 7.3 of https://lwn.net/Articles/257209/

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Jun 9, 2012

Safety0ff uploaded file massif.jpg (259.0 KiB)

Net Autogame with various ais
massif.jpg

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Feb 3, 2013

Per changed status from reopened to closed

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Feb 3, 2013

Per changed resolution from `` to duplicate

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant