memory leak

Everything related to the code /
Tout ce qui touche au code
Post Reply
User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

memory leak

Post by zuzuf » Mon Jun 15, 2009 9:19 pm

It seems there is a big memory leak in the code :(

I played nearly 2 hours, and it ended using 3.1GB of RAM :shock: , it didn't even release this memory after game ended :cry: so it is definitely a memory leak, and a big one :evil:
=>;-D Penguin Powered

User avatar
Griswoldz
Posts: 33
Joined: Sun Jun 07, 2009 11:26 pm
Location: Poland
Contact:

Re: memory leak

Post by Griswoldz » Mon Jun 15, 2009 9:22 pm

The code needs debugging then. I would suggest Cheat engine trainer maker, as it can actually show WHAT writes WHERE. Perhaps it will help :P.

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: memory leak

Post by zuzuf » Mon Jun 15, 2009 11:33 pm

There are lots of memory allocation/deallocation during a single frame/tick, it'll be a real nightmare to find the leak analyzing the code and what it's doing. I think a good way to trace the leak is to find when we introduced it by testing previous revisions, just spawn 1000 vs 1000 units, if there is the leak it'll be obvious. Hopefully search time is logarithmic :P. I'll do that tomorrow :D
=>;-D Penguin Powered

User avatar
Griswoldz
Posts: 33
Joined: Sun Jun 07, 2009 11:26 pm
Location: Poland
Contact:

Re: memory leak

Post by Griswoldz » Mon Jun 15, 2009 11:48 pm

Alright :D. I'll be ready to test the new upcoming version by focusing on RAM-hunger of it. Rawr.

User avatar
Balthazar
Moderator
Posts: 2055
Joined: Wed Nov 01, 2006 4:31 pm
Location: Russian Federation
Contact:

Re: memory leak

Post by Balthazar » Tue Jun 16, 2009 5:16 am

In this case I`ll try to do the same test on a8,a7 and a6 :P

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: memory leak

Post by xpoy » Tue Jun 16, 2009 6:41 am

I'll help in this in tonight.
:p Best in debug

milipili
Posts: 545
Joined: Thu Nov 02, 2006 8:52 am
Location: Paris (France)
Contact:

Re: memory leak

Post by milipili » Tue Jun 16, 2009 10:39 am

"Intruments" on OS X already told where the leak is. It will be fixed as soon as possible (unless zuzuf fixes it before ^^)
Damien Gerard
Ta3d & Yuni Developer

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: memory leak

Post by zuzuf » Tue Jun 16, 2009 11:07 am

nice, where is it ? :mrgreen:
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: memory leak

Post by xpoy » Tue Jun 16, 2009 12:00 pm

The memory wasn't in excess of the accident when spawn lots of units. I spawn 10000 units for test. :P
Interesting, spwan 0 0 10000 in a land and sea map faster than spawn 0 0 1000 units in a land map.


This is crash when close that game table:
07D9FE9C 7C8023ED ntdll.ZwDelayExecution kernel32.7C8023E7 07D9FEF0
07D9FEA0 00000000 Arg1 = 00000000
07D9FEA4 07D9FEC8 Arg2 = 07D9FEC8
07D9FEF4 7C802451 ? kernel32.SleepEx kernel32.7C80244C 07D9FEF0
07D9FEF8 00000064 Timeout = 100. ms
07D9FEFC 00000000 Alertable = FALSE
07D9FF04 6813EA21 ? <jmp.&KERNEL32.Sleep> SDL.6813EA1C 07D9FF00
07D9FF08 00000064 Timeout = 100. ms
07D9FF14 004DDD3C <jmp.&SDL.SDL_Delay> ta3d.004DDD37 07D9FF10
07D9FF24 00658D8B 包含ta3d.004DDD3C ta3d.00658D88 07D9FF20
07D9FF44 6810A2EC 包含ta3d.00658D8B SDL.6810A2EA 07D9FF40
07D9FF64 6813E4C9 SDL.6810A2B0 SDL.6813E4C4 07D9FF60
07D9FF84 77C0A3B0 包含SDL.6813E4C9 msvcrt.77C0A3AD 07D9FF80


Thus that was a menu show problem. :P

It crash when close a old thread and sdl_delay, like a wrong argc or a pointer wrong struct

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: memory leak

Post by zuzuf » Tue Jun 16, 2009 2:08 pm

spawning 10000 units is unwise ... unless you set up the maximum unit per player count to something like 10000 instead of 2000 (which is already too much if AI can get so much units)
=>;-D Penguin Powered

User avatar
Balthazar
Moderator
Posts: 2055
Joined: Wed Nov 01, 2006 4:31 pm
Location: Russian Federation
Contact:

Re: memory leak

Post by Balthazar » Tue Jun 16, 2009 2:41 pm

Yeah, I`ve noticed the same bug.... on 0.6.0.a8, a7 and a6. But when i quit TA3D the used memory frees, so no memory losing detected.

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: memory leak

Post by xpoy » Tue Jun 16, 2009 2:46 pm

I used ahpla 8, and play a 1000 vs 1000 units.
This is test PC:
AMD athlon 64 3000+
1.99 GHz, 1.00 GB mem
Gfx5200


And OMG, I love this. It was normal FPS, and all work normal ingame! I didn't notice that lots of memory leak, but be 270 MB when alt tab to game, 160 MB when alt tab out. And first time alt tab made game freez in 10 seconds. First time spawn was very slow, but next be faster.
When I lose, yes , AI kick my control nothings ass, the memory be 32MB, just crash when quit table.
And yes, I should try defeat 1000 KROGs at now, haha

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: memory leak

Post by zuzuf » Tue Jun 16, 2009 3:42 pm

when you exit TA3D, the OS frees the memory it allocated. This is normal behaviour since a program allocates "virtual memory" that is mapped onto the system RAM when needed (a program can allocate more memory than you have RAM as long as the CPU can address it, so 3.2GB max on 32bits CPUs and much more with a 64bits one :P, it'll only swap to the disk)
=>;-D Penguin Powered

User avatar
Balthazar
Moderator
Posts: 2055
Joined: Wed Nov 01, 2006 4:31 pm
Location: Russian Federation
Contact:

Re: memory leak

Post by Balthazar » Tue Jun 16, 2009 3:54 pm

it didn't even release this memory after game ended
- sorry, my bad. Wrong translated :P

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: memory leak

Post by xpoy » Wed Jun 17, 2009 6:23 am

This is a platform or system proble, I didn't meet it even 1 hour play.
But it was really cost some time for cache that first time switch in Strategic perspective and normal perspective.
But all other work well.
And there are 90MB used when quit game, I alt tab out then in the game, mem be normal 20MB.

The mouse shouldn't be slow when game fell tired, just made mouse and keyboard work normal then a big part finshed

In last, I got one crash, oh it really cost long time.
And a intereting thing, in the last 5 mins, I found the metal and energy text be fuzzy
Attachments
stdout.rar
(19.58 KiB) Downloaded 338 times

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: memory leak

Post by zuzuf » Wed Jun 17, 2009 8:08 am

I run TA3D with Valgrind which tolds me there was a total memory leak of 48MB for a very short game (a few minutes running at 3fps - yes this is because of Valgrind) with 100 units spawned on the map. So there is definitely a big memory leak.
=>;-D Penguin Powered

User avatar
Balthazar
Moderator
Posts: 2055
Joined: Wed Nov 01, 2006 4:31 pm
Location: Russian Federation
Contact:

Re: memory leak

Post by Balthazar » Wed Jun 17, 2009 3:58 pm

milipili wrote:"Intruments" on OS X already told where the leak is. It will be fixed as soon as possible (unless zuzuf fixes it before ^^)
Tell us where is it :P

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: memory leak

Post by xpoy » Wed Jun 17, 2009 5:00 pm

There are Linux used in malloc manage, but Win32 just used in malloc count, or some other nearly shape wrong.
I just guessing, need milipili told us....

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: memory leak

Post by zuzuf » Wed Jun 17, 2009 5:22 pm

Those ugly leaks seem to be gone :P
=>;-D Penguin Powered

User avatar
Balthazar
Moderator
Posts: 2055
Joined: Wed Nov 01, 2006 4:31 pm
Location: Russian Federation
Contact:

Re: memory leak

Post by Balthazar » Wed Jun 17, 2009 6:05 pm

Whould you build a new test binaries to be sure ? :P

P.S. Maybe end sission crash have been connected to this.

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: memory leak

Post by zuzuf » Wed Jun 17, 2009 6:21 pm

I doubt it was because a memory leak doesn't produce memory corruption, this is something else.
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: memory leak

Post by xpoy » Thu Jun 18, 2009 8:45 am

调用堆栈: 线程 00000858, 条目 2
地址=0DC8F094
堆栈=7C81AD0A
函数过程 / 参数=ntdll.CsrClientCallServer
调用来自=kernel32.7C81AD04
结构=0DC8F090

well, there are a problem in win32 input code.
It crash when I spawn 1000vs 1000 unit and zoom out lot times as soon as screen start refresh

log file:
stdout.rar
(17.67 KiB) Downloaded 284 times

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: memory leak

Post by zuzuf » Thu Jun 18, 2009 4:08 pm

if you remove *.lua files from scripts/ and *.3dm from objects3d/ does it still crash ?
Does it still crash with only totala1.hpi/totala2.hpi, with and without TA:CC files ?
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: memory leak

Post by xpoy » Thu Jun 18, 2009 5:26 pm

It was a lua problem, I only test 2 times, look like delete lua file fix this problem, I spawn then ctrl_z/ ctrl_z/...... and zoom out zoom in, game keep going without any wrong. /:^]

But found new thing:
My all units die by somethings, But I think there no things could kill 300 units around all map in a second, log file
Attachments
stdout.rar
(21.95 KiB) Downloaded 253 times

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: memory leak

Post by zuzuf » Thu Jun 18, 2009 7:05 pm

maybe it's a chained explosion of commanders :P, or AI's secret super weapon :mrgreen:

But I know a 3rd party unit capable of killing thousands of units at once : the Armageddon, it's a kind of atomic bomb, except it's radius is much bigger :mrgreen: (if you use it on small maps, no one wins ...)

Also a ctrl+D can suicide all your units if you accidentally press it ...
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: memory leak

Post by xpoy » Thu Jun 18, 2009 7:57 pm

Yes, it can be a wrong ctrl_s,really nearly
But I found log didn't help in this /:^[
May log user input cost too many CPU, but it was need in ahpha version, maybe, :)

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests