Page 1 of 1

This is why I stopped playing minetest

PostPosted: Sun Jul 01, 2012 15:27
by lkjoel
I now am trying to fix minetest, but this is one of the reasons why I stopped:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
==12107== LEAK SUMMARY:
==12107==    definitely lost: 96,200 bytes in 518 blocks
==12107==    indirectly lost: 1,522,455 bytes in 3,565 blocks
==12107==      possibly lost: 33,554,512 bytes in 3 blocks
==12107==    still reachable: 46,068 bytes in 422 blocks
==12107==         suppressed: 0 bytes in 0 blocks
==12107== Reachable blocks (those to which a pointer was found) are not shown.
==12107== To see them, rerun with: --leak-check=full --show-reachable=yes
==12107==
==12107== For counts of detected and suppressed errors, rerun with: -v
==12107== Use --track-origins=yes to see where uninitialised values come from
==12107== ERROR SUMMARY: 10000065 errors from 800 contexts (suppressed: 1614459 from 49)

This means that each time you run minetest, you lose ~35MB of RAM (until you reboot)!
I'll try to fix some of these issues though

PostPosted: Sun Jul 01, 2012 21:56
by cosarara97
Mine is different, although I don't know what does it mean, although it looks worse to me :/ (just ran in valgrind)
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
==31278== LEAK SUMMARY:
==31278==    definitely lost: 193,454 bytes in 1,385 blocks
==31278==    indirectly lost: 15,908,560 bytes in 10,764 blocks
==31278==      possibly lost: 35,712,096 bytes in 7 blocks
==31278==    still reachable: 74,115 bytes in 547 blocks
==31278==         suppressed: 0 bytes in 0 blocks
==31278== Rerun with --leak-check=full to see details of leaked memory
==31278==
==31278== For counts of detected and suppressed errors, rerun with: -v
==31278== Use --track-origins=yes to see where uninitialised values come from
==31278== ERROR SUMMARY: 111525 errors from 56 contexts (suppressed: 2 from 2)

Well, hope you can fix it.

PostPosted: Sun Jul 01, 2012 22:11
by lkjoel
Yeah, that's way worse (50MB). I'll try my best

PostPosted: Mon Jul 02, 2012 02:17
by cy
If you're running Linux, it puts processes into completely abstract address spaces. that means it's impossible for a program to acquire memory that Linux cannot then go mark as usable again after that process has died. All memory acquisition is recorded and accounted for by the kernel. The only operating system really known for actually leaking memory that remained unclaimable after the process was stopped was Win95 or earlier (not counting WinNT).

It's true that minetest client has a lot of leaks though. Many probably Irrlicht bugs. The end result is it starts eating your RAM if you exit to Menu (and not to OS) too many times. Then you kill the process and all that RAM is free. I just exit to OS every time since the time it takes to start up the menu is practically zero. Never had any problems.

To reiterate, code to prevent memory leaks 100% already exists for every program. Code to free unused memory without restarting the process is technically redundant.

PostPosted: Mon Jul 02, 2012 02:18
by cy
Seriously Joel your treehouse is amazing. :/ Don't leave us!

PostPosted: Mon Jul 02, 2012 02:50
by Melkor
lkjoel wrote:I now am trying to fix minetest, but this is one of the reasons why I stopped:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
...

This means that each time you run minetest, you lose ~35MB of RAM (until you reboot)!
I'll try to fix some of these issues though


good to know this!
is complicated when you're a noob trying to do mods, log in and out all the time of minetest
thanks!

PostPosted: Mon Jul 02, 2012 16:58
by lkjoel
I'm not leaving persay, but I'm rather gonna try to fix as many leaks as possible (to the irrlicht limit, of course), so I won't be playing for a while.

PostPosted: Tue Jul 03, 2012 09:08
by qznc
lkjoel wrote:This means that each time you run minetest, you lose ~35MB of RAM (until you reboot)!


Sorry, but "until you reboot" is not correct. RAM is freed when an application exits.

RAM is request by an application from the operating system. So the OS knows what RAM is used by which app. Additionally, the OS knows which apps are running and when they exit. Hence, the OS can easily free the RAM an application got as soon as the app exits. It is not even a costly operation.

The problem with memory leaks are long running applications. For example, if a minetest server leaks memory it might grow over the days/months. At some point the physical RAM is exhausted and the OS will start swapping, which means everything becomes slow. If swap does not suffice anymore, the OS can only kill processes to free memory. Probably, the minetest server will simply be killed.

Is there any leak in the server code? It should not require Irrlicht.

PostPosted: Tue Jul 03, 2012 17:09
by lkjoel
qznc wrote:
lkjoel wrote:This means that each time you run minetest, you lose ~35MB of RAM (until you reboot)!


Sorry, but "until you reboot" is not correct. RAM is freed when an application exits.

RAM is request by an application from the operating system. So the OS knows what RAM is used by which app. Additionally, the OS knows which apps are running and when they exit. Hence, the OS can easily free the RAM an application got as soon as the app exits. It is not even a costly operation.

The problem with memory leaks are long running applications. For example, if a minetest server leaks memory it might grow over the days/months. At some point the physical RAM is exhausted and the OS will start swapping, which means everything becomes slow. If swap does not suffice anymore, the OS can only kill processes to free memory. Probably, the minetest server will simply be killed.

Is there any leak in the server code? It should not require Irrlicht.

That is the problem. It doesn't free when the app exists. The app must free the RAM by itself, because the system cannot do that.
Memory leaks mean that the application actually allocates memory somewhere, but then it doesn't free it. The OS has NO WAY OF KNOWING if that part of the memory is used or not, therefore it just exists there without anyone using it.

I'm sorry, you just don't know how computers work.

PostPosted: Tue Jul 03, 2012 19:07
by qznc
lkjoel wrote:That is the problem. It doesn't free when the app exists. The app must free the RAM by itself, because the system cannot do that.
Memory leaks mean that the application actually allocates memory somewhere, but then it doesn't free it. The OS has NO WAY OF KNOWING if that part of the memory is used or not, therefore it just exists there without anyone using it.

I'm sorry, you just don't know how computers work.


That is an interesting OS you are using there. Every Desktop OS I know uses virtual memory to sandbox applications. Is minetest running on something other than Windows, OS X, iOS, Linux, BSD, DOS, Android, Solaris? Please help, I want to learn computers.

PostPosted: Tue Jul 03, 2012 19:53
by lkjoel
Memory leak in wikipedia: "A memory leak, in computer science (or leakage, in this context), occurs when a computer program consumes memory but is unable to release it back to the operating system.". You get that now?

PostPosted: Tue Jul 03, 2012 21:08
by cosarara97
lkjoel wrote:Memory leak in wikipedia: "A memory leak, in computer science (or leakage, in this context), occurs when a computer program consumes memory but is unable to release it back to the operating system.". You get that now?

qznc is right... The OS gives every program a space in the memory, and when it finishes, all that memory gets free. It doesn't matter if the program lost it's track it while it was running, that's what virtual memory is about.
You know, if I lost 50 MBs of RAM every time I ran minetest, I would have no ram now, because it's been arround 2 weeks since i rebooted this PC, and I open and close minetest lots of times when I install mods. I have 2 GBs of ram, and if what you think were true, I could run MT just ~40 times before running out of RAM.
Memory leaks make memory unavaiable to the system while the program is running, but not after it's closed.
Just open and close MT 40 times in a netbook and see :)
Oh, yes, and from Memory leak in wikipedia (just some paragraphs below): "Memory leaks may not be serious or even detectable by normal means. In modern operating systems, normal memory used by an application is released when the application terminates."

But I'd, of course, be very happy if you fixed all those memory leaks :)

PostPosted: Tue Jul 03, 2012 21:32
by lkjoel
Well, ok, but for some reason the system DOES slow down after a couple times of minetest were instanced (Ubuntu 12.10, 8GB RAM, 64-bit AMD A6). So there are a few things that do get lost after a couple of times (for example, I think that objects that are not freed are left hanging, as it is given to a random stop of the memory, no association to the program, except for the pointer).

PostPosted: Thu Jul 05, 2012 22:54
by glomie
lkjoel wrote:Well, ok, but for some reason the system DOES slow down after a couple times of minetest were instanced (Ubuntu 12.10, 8GB RAM, 64-bit AMD A6). So there are a few things that do get lost after a couple of times (for example, I think that objects that are not freed are left hanging, as it is given to a random stop of the memory, no association to the program, except for the pointer).

Or a leak/bug in nvidia/catalyst driver as usual...

PostPosted: Fri Jul 06, 2012 02:04
by lkjoel
Uh, I don't use that

PostPosted: Fri Jul 06, 2012 11:24
by mauvebic
glomie wrote:Or a leak/bug in nvidia/catalyst driver as usual...


Dont blame ATI/NVIDIA. I know its the popular thing for linux devs to blame everything but themselves, but even when they have the source code they cant get it right. Been using linux for 8 years now, and i've never had a smooth wifi experience. Apart from which the linux gurus seem to change their minds every year, not long ago i was told ATI was shit and i should buy NVIDIA, i did. When i started having problems with NVIDIA drivers suddenly NVIDIA was the bad guy and ATI was suddenly better. So i stop listening to these (clueless) people a long time ago. Failing that, they tell you its free and you should pay them if you want them to fix their own shit code. Which is pretty much how linux support companies make their living.