project-navigation
Personal tools

Author Topic: 2.4dev mem usage (ram eaten up)  (Read 7561 times)

Offline Muton

  • Sergeant
  • *****
  • Posts: 496
    • View Profile
2.4dev mem usage (ram eaten up)
« on: December 04, 2011, 08:49:52 am »
Because of lot map errors
i tried some time ago to loop trough all maps and check for errors.
(attached patch [cli command maptest])

There are 2 problems so far
one major is
if you call cli
map day +africa
your available ram is decreasing each time you call a map.

Ive tested this on Win32 and on a fresh debian linux
On windows all ram is used even the swap and than the game run extremely slow
On Linux the ram isnt used much but the swap space used increase until the game simply crash

Im not sure what is causing this
because on windows (im a winuser) ufo.exe dont consume more ram.
Just the system consume more and more ram.

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: 2.4dev mem usage (ram eaten up)
« Reply #1 on: December 04, 2011, 05:23:25 pm »
there is already a unittest for this. did you check whether it's the same there, too - otherwise you might have missed some cleanup function call.

src/test/test_mapdef.c (compile the c::b target testall)

Offline Muton

  • Sergeant
  • *****
  • Posts: 496
    • View Profile
Re: 2.4dev mem usage (ram eaten up)
« Reply #2 on: December 08, 2011, 08:25:49 am »
There is a memleak!
tracker 3454274

On a landing mission the memory usage increase!

Just shoot down a ufo and save the game
send a landing team an restart the mission (dont abort the mission, just restart [loop 10 times])
Mem used increase ...
Now abort the mission and reload the savegame and start the mission
abort -> load the savegame -> start the mission (loop 10 times)
Mem used increase ...
use cli command
map day +africa (loop 10 times)
mem used increase ...


@testall
testall doesnt test all.
There is a black hole in africa but testall isnt reporting any error.
Or report any
ERROR: CM_InlineModel: Error cannot find model '*4'
"real world" error.
Even worse
testall does crash (if called from source) or stop (idle) working (if called from ufoinstall) on error
Running Test : testMoveEntities
ERROR: Couldn't load maps/test_routing.bsp
testall.exe --enable-all --console --log
logs attached

The reason why is well known 4me
Shutdown server: Server crashed.
Ive seen this error often and than a
map day +bla
call isnt executed
Tried (source) a lot of things to restart the server
but without luck. (doxygen link returns 403 error)
So i leave it to you .. :)

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: 2.4dev mem usage (ram eaten up)
« Reply #3 on: December 08, 2011, 11:06:38 pm »
maybe the console command mem_stats helps to tackle it down

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: 2.4dev mem usage (ram eaten up)
« Reply #4 on: December 08, 2011, 11:51:25 pm »
I lend my anecdotal support to this. I have noticed before if I play the game for more than 20-30 minutes, it has caused extreme slow-down in my system. I don't know anything about memory leaks, but I have definitely experienced this problem when I play the game for longer periods (which is not too often anymore).

Offline Muton

  • Sergeant
  • *****
  • Posts: 496
    • View Profile
Re: 2.4dev mem usage (ram eaten up)
« Reply #5 on: December 09, 2011, 01:20:23 pm »
mem_stats shows no unusual mem usage
but valgrind does.

attached

Because this is beyond my scope ...

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: 2.4dev mem usage (ram eaten up)
« Reply #6 on: December 10, 2011, 08:27:30 am »
the problems that your valgrind log is showing here are problems in zlib and mesa - not in ufoai

Offline Muton

  • Sergeant
  • *****
  • Posts: 496
    • View Profile
Re: 2.4dev mem usage (ram eaten up)
« Reply #7 on: December 12, 2011, 09:58:41 am »
Yesterday i tried to find the root of the problem, but ....

Googling the memleak lead to an explanation
Its a handle-memleak
On windows
after running the game and loading a map
procesexplorer reveals >900 open handles
during reloading handles are released and again opened
If i do this in a loop i can see more handles are opened than released
in the end there are more than 1200 handles open

I than took a look into the code to pinpoint the problem
Followed functions
SV_Map->SV_InitGame->SV_InitGameProgs->TH_MutexCreate
SV_ShutdownGameProgs and TH_MutexDestroy is also called

Hard to follow all this functions!
Is there a doc that shows what function is called when ...
http://ufoai.ninex.info/doxygen/ = 403

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: 2.4dev mem usage (ram eaten up)
« Reply #8 on: December 12, 2011, 09:12:12 pm »
http://ufoai.ninex.info/wiki/images/Callgraph.png

but i doubt that it'll help a lot in this case

Offline iamaloner

  • Rookie
  • ***
  • Posts: 26
    • View Profile
Re: 2.4dev mem usage (ram eaten up)
« Reply #9 on: March 11, 2012, 08:52:02 pm »
I am not an coder or expert my newbie opinion is that trying new stuff with Quake 2 engine is harder and there is greater chances for glitches, bugs that could eat up alot of ram, proccesor, graphic card... Idk why dont you use Quake 3 engine :P

Offline Kildor

  • Project Artist
  • Captain
  • ***
  • Posts: 757
  • Project mapper and some other stuff`er
    • View Profile
    • http://ufoai.nx0.ru
Re: 2.4dev mem usage (ram eaten up)
« Reply #10 on: March 12, 2012, 05:20:39 am »
Because when project was started there was no Quake 3 sources?
The Id tech 3 was released on August 19, 2005, the first tech demo of UFO:AI was done near February 2004.
And now rewriting the game simply kills the project.

Also, some Id tech 3 features are in ufoai already, and even more.