Increasing Ram usage / Memory Leak (Scripts)
#1

I never really considered this to be a problem, (as I am trying my best to write clean and optimized code) - but whatever i did in my new update (and whenever there are players on) causes massive ram usage. in 24 hours it consumes about 40% of 2gb ram on a VPS. - The ram usage drops back down to 8-10% when I restart the server, and slowly increases by time and by amount of players.

Anyone who had past experiences with leaks and how to avoid it? Which code could be causing slow build-ups like this, any way to detect it, and what is not recommended doing? I read a bit on the forums, but most replies are "do not blabalbalal" and it's completely nonsense - either way made by total newbies or guys who doesn't know what a memory leak is. So I decided to put a new topic here.
(For example: do not use OnPlayerUpdate() at all. - like come on, it matters which code you got there)

and the "new update " would mean a version update consisting of several upgraded and added systems, so no way to "go back" and see what it could be.
Could "flushing" variables through a command work? Like I choose one system I'd like to try, and i flush all the variables connected to it- and check the ram usage afterwards - Can variables hold that much information?
- I guess not, as memory leaks are just invalid adressed memory that never gets furtherly processed, if I got that correctly.

Any pointers, anything I could read more about - anything that could point me in a direction here would be really useful. I am not 100% familiar on the topic yet, and I hope to be more informed by seeing your replies. I believe I am doing something wrong, but I hope to learn from it if I find what it could be.

Thank you.
Reply
#2

It's a plugin issue because memory usage of a normal Pawn script is fixed (size of the globals + size of the stack). Using unthreaded MySQL queries may cause memory leaks if you forget to free the result (cache_delete).
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
It's a plugin issue because memory usage of a normal Pawn script is fixed (size of the globals + size of the stack). Using unthreaded MySQL queries may cause memory leaks if you forget to free the result (cache_delete).
Thanks for a very clarifying reply - it makes a lot of sense, although my first impression was more it could be an issue in regards of arrays and variables. Even recursing functions scared me a bit, as they are terribly hard to find in some cases.

If it's a plugin related issue, how come this happens? Only changes i did in regards of plugins would be the streamer (by incognito) - that by adding a few new objects (15k of them are added).

All other plugins and things in relation remains untouched, except for a new messages on IRC.
Reply
#4

Some plugins, such as mysql, doesn't free the result cache when you use unthreaded queries (mysql_query), so it means that every time a 'select' query gets executed, results are stored in RAM but never cleared, and so on, so it keeps increasing your RAM usage.
Reply
#5

Quote:
Originally Posted by iKarim
Посмотреть сообщение
Some plugins, such as mysql, doesn't free the result cache when you use unthreaded queries (mysql_query), so it means that every time a 'select' query gets executed, results are stored in RAM but never cleared, and so on, so it keeps increasing your RAM usage.
Fully aware of the risk here, as MySQL does what it is told to do and I'm familiar with it.
Might often be the most simple mistakes that causes issues like this, so I'll go through and either confirm it or prove otherwise. Although I've spent some time checking this earlier, as this was my initial thought regarding the increasing ram (and especially since it increases for more players - then there's more data to load, and you keep building up memory..)

EDIT:

It can't be the mysql_query, as the calls are equal to one another. (unless I call it twice somewhere).
Potentially, how much can a query cache hold for reading? Several mb?

A gamemode reload (GMX) doesn't flush the memory, leading me to believe it could be a plugin as suggested.
Reply
#6

Quote:
Originally Posted by Gamer_Z
Посмотреть сообщение
load up an empty instance of the server with valgrind, then test all plugins you use separatly, each time running valgrind too. Valgrind will tell you if a plugin has memory leaks by reporting it as inaccessible/lost memory.
I would assume this requires me to compile the source of the plugins with some parameters in order to get correct prints, right? (I never got C++ compiler to work yet)

I am not too familiar with Valgrind, however it seems really cool (and helpful in my case).
Reply
#7

It is probably because of ur filterscripts or plugins causing the problem!
or is it just ur graphics card
Reply
#8

One plugin in use on my gamemode: (lacking functionality, unknown gamemode..)

Код:
==8128== Memcheck, a memory error detector
==8128== Copyright © 2002-2013, and GNU GPL'd, by Julian Seward et al.
==8128== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==8128== Command: ./samp03svr --leak-check=full
==8128==
==8128== Conditional jump or move depends on uninitialised value(s)
==8128==    at 0x80822F6: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x80835A8: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x807EC25: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x806EF28: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x807B9E6: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x80AF584: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x80AA0E5: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x41C9AF2: (below main) (libc-start.c:287)
==8128==

Started server on port: 9999, with maxplayers: 12 lanmode is ON.

^C==8128== Conditional jump or move depends on uninitialised value(s)
==8128==    at 0x8066B40: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x8070EF6: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x80710E5: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x80AB31E: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x80AA24B: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x41C9AF2: (below main) (libc-start.c:287)
==8128==
==8128== Conditional jump or move depends on uninitialised value(s)
==8128==    at 0x8077476: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x806E9AA: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x8071068: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x80710E5: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x80AB31E: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x80AA24B: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==8128==    by 0x41C9AF2: (below main) (libc-start.c:287)
==8128==
==8128==
==8128== HEAP SUMMARY:
==8128==     in use at exit: 3,323 bytes in 104 blocks
==8128==   total heap usage: 5,858 allocs, 5,754 frees, 32,079,356 bytes allocated
==8128==
==8128== LEAK SUMMARY:
==8128==    definitely lost: 992 bytes in 62 blocks
==8128==    indirectly lost: 176 bytes in 32 blocks
==8128==      possibly lost: 35 bytes in 1 blocks
==8128==    still reachable: 2,120 bytes in 9 blocks
==8128==         suppressed: 0 bytes in 0 blocks
==8128== Rerun with --leak-check=full to see details of leaked memory
==8128==
==8128== For counts of detected and suppressed errors, rerun with: -v
==8128== Use --track-origins=yes to see where uninitialised values come from
==8128== ERROR SUMMARY: 31 errors from 3 contexts (suppressed: 0 from 0)
I would need some help here- no matter which plugin i start the server with (alone) - it reports 992 bytes as lost.



And When all plugins are in use on my gamemode:

Код:
==9099== Memcheck, a memory error detector
==9099== Copyright © 2002-2013, and GNU GPL'd, by Julian Seward et al.
==9099== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==9099== Command: ./samp03svr --leak-check=full
==9099==
==9099== Conditional jump or move depends on uninitialised value(s)
==9099==    at 0x80822F6: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80835A8: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x807EC25: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x806EF28: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x807B9E6: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AF584: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AA0E5: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x41C9AF2: (below main) (libc-start.c:287)
==9099==

Started server on port: 9999, with maxplayers: 12 lanmode is ON.

==9099== Thread 2:
==9099== Conditional jump or move depends on uninitialised value(s)
==9099==    at 0x402D3F7: strlen (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==9099==    by 0x4114584: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.19)
==9099==    by 0x47F001D: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/plugins/irc.so)
==9099==    by 0x47F7D11: boost::asio::detail::reactive_socket_recv_op<boost::asio::mutable_buffers_1, boost::_bi::bind_t<void, boost::_mfi::mf2<void, Client, boost::system::error_code const&, unsigned int>, boost::_bi::list3<boost::_bi::value<boost::shared_ptr<Client> >, boost::arg<1> (*)(), boost::arg<2> (*)()> > >::do_complete(boost::asio::detail::task_io_service*, boost::asio::detail::task_io_service_operation*, boost::system::error_code const&, unsigned int) (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/plugins/irc.so)
==9099==    by 0x480F28B: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/plugins/irc.so)
==9099==    by 0x480E161: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/plugins/irc.so)
==9099==    by 0x47DFB60: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/plugins/irc.so)
==9099==    by 0x404FF71: start_thread (pthread_create.c:312)
==9099==    by 0x429E2AD: clone (clone.S:129)
==9099==
==9099== Thread 3:
==9099== Conditional jump or move depends on uninitialised value(s)
==9099==    at 0x8077736: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80740C2: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x808EC9C: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x8074845: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80763FD: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x404FF71: start_thread (pthread_create.c:312)
==9099==    by 0x429E2AD: clone (clone.S:129)
==9099==
==9099== Conditional jump or move depends on uninitialised value(s)
==9099==    at 0x80822F6: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80835A8: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x8080D57: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x807367F: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x808EC9C: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x8074845: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80763FD: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x404FF71: start_thread (pthread_create.c:312)
==9099==    by 0x429E2AD: clone (clone.S:129)
==9099==
==9099== Conditional jump or move depends on uninitialised value(s)
==9099==    at 0x8077736: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80750D0: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80763FD: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x404FF71: start_thread (pthread_create.c:312)
==9099==    by 0x429E2AD: clone (clone.S:129)
==9099==
==9099== Conditional jump or move depends on uninitialised value(s)
==9099==    at 0x8077736: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80761CB: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80763FD: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x404FF71: start_thread (pthread_create.c:312)
==9099==    by 0x429E2AD: clone (clone.S:129)
==9099==
==9099== Thread 1:
==9099== Mismatched free() / delete / delete []
==9099==    at 0x402B838: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==9099==    by 0x806D4AE: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AED31: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AEF01: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AA139: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x41C9AF2: (below main) (libc-start.c:287)
==9099==  Address 0x15829b68 is 0 bytes inside a block of size 7 alloc'd
==9099==    at 0x402ADFC: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==9099==    by 0x807E2F7: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x808106D: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x807367F: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x808EC9C: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x8074845: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80763FD: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x404FF71: start_thread (pthread_create.c:312)
==9099==    by 0x429E2AD: clone (clone.S:129)
==9099==
==9099== Conditional jump or move depends on uninitialised value(s)
==9099==    at 0x8077476: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x806E9AA: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x806EB02: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x807BBA7: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x8071B42: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x807C192: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x806D61E: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x807C30E: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AC298: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80C9042: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80D09D3: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80B5514: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==
==9099== Mismatched free() / delete / delete []
==9099==    at 0x402B838: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==9099==    by 0x806D4AE: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x8071DCB: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x807BC4F: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AED3C: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AEF01: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AA139: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x41C9AF2: (below main) (libc-start.c:287)
==9099==  Address 0x11cb6108 is 0 bytes inside a block of size 78 alloc'd
==9099==    at 0x402ADFC: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==9099==    by 0x807E2F7: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x808106D: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x807367F: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x808EC9C: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x8074845: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80763FD: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x404FF71: start_thread (pthread_create.c:312)
==9099==    by 0x429E2AD: clone (clone.S:129)
==9099==
==9099== Thread 3:
==9099== Syscall param socketcall.sendto(msg) points to uninitialised byte(s)
==9099==    at 0x4057368: sendto (socket.S:98)
==9099==    by 0x808ED15: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x807D0EE: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x8080217: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x8074C39: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80763FD: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x404FF71: start_thread (pthread_create.c:312)
==9099==    by 0x429E2AD: clone (clone.S:129)
==9099==  Address 0x5e9ba27 is 143 bytes inside a block of size 576 alloc'd
==9099==    at 0x402A17C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==9099==    by 0x804C989: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x807EC8C: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x806EF28: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x807B9E6: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AF584: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AA0E5: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x41C9AF2: (below main) (libc-start.c:287)
==9099==
==9099== Thread 1:
==9099== Conditional jump or move depends on uninitialised value(s)
==9099==    at 0x80C9E24: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80CAB17: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80D0E86: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AF006: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AA139: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x41C9AF2: (below main) (libc-start.c:287)
==9099==
==9099== Conditional jump or move depends on uninitialised value(s)
==9099==    at 0x80AC534: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80C9ED0: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80CAB17: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80D0E86: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AF006: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AA139: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x41C9AF2: (below main) (libc-start.c:287)
==9099==
==9099== Conditional jump or move depends on uninitialised value(s)
==9099==    at 0x80AC53B: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80C9ED0: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80CAB17: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80D0E86: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AF006: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AA139: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x41C9AF2: (below main) (libc-start.c:287)
==9099==
^C==9099== Conditional jump or move depends on uninitialised value(s)
==9099==    at 0x8066B40: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x8070EF6: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80710E5: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AB31E: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x80AA24B: ??? (in /var/www/html/gpx/_SERVERS/accounts/esv5/185.107.96.218.9999/samp03svr)
==9099==    by 0x41C9AF2: (below main) (libc-start.c:287)
==9099==
==9099==
==9099== HEAP SUMMARY:
==9099==     in use at exit: 217,364 bytes in 220 blocks
==9099==   total heap usage: 3,822,375 allocs, 3,822,155 frees, 482,622,673 bytes allocated
==9099==
==9099== LEAK SUMMARY:
==9099==    definitely lost: 2,329 bytes in 68 blocks
==9099==    indirectly lost: 35,017 bytes in 52 blocks
==9099==      possibly lost: 175,040 bytes in 78 blocks
==9099==    still reachable: 4,978 bytes in 22 blocks
==9099==         suppressed: 0 bytes in 0 blocks
==9099== Rerun with --leak-check=full to see details of leaked memory
==9099==
==9099== For counts of detected and suppressed errors, rerun with: -v
==9099== Use --track-origins=yes to see where uninitialised values come from
==9099== ERROR SUMMARY: 18872 errors from 14 contexts (suppressed: 0 from 0)

If I understood your instructions correctly, I should load one plugin at a time, and see which one's causing it? Because, if one or more plugins aren't used - my gamemode wont load - and that means none of the functionality will run.

Or should I make a blank gamemode for the purpose of testing it?

Thanks for your help so far @Gamer_Z
Reply
#9

Quote:
Originally Posted by Gamer_Z
Посмотреть сообщение
I think I would do it as follows:

1) indeed use a blank gamemode for each plugin (which uses the plugin functionality just as your "full" gamemode does)
2) run only that plugin and the gamemode just for the plugin which resembles your gamemode usage with valgrind
3) let a few testers join and perform the same actions (maybe use raksamp bots or something for reproducability)
4) let them leave
5) shutdown the server
6) compare to the base measurement of you 992 bytes / 62 blocks lost, this means sa-mp leaks only 992 bytes by itself. It's not uncommon for applications to do this with a set of "static / one time initialized" variables that are not RAII encapsulated / are not freed on close (because they let the OS do this and thus purposefully leak, I call this a "static leak" - one time purposeful leak, your problem is the opposite of that, a plugin or multiple plugins keep leaking memory all the time on specific actions and don't release them when needed).
7) from your full report you know that some plugins leak memory / don't clean up on exit, time to find out which ones

Maybe test each plugin with a different user count / dfferent usage count (e.g. query count + free count). If a plugin really leaks memory then you will see an increase in lost bytes / blocks when using more of the plugin functions. If a plugin does not leak then you should see the same amount of lost bytes / blocks with different usage scenarios.

Once you identify the leaking plugin(s) check if you are not purposefully telling the plugin to leak (from your script). If that's done then contact the author(s) of the plugin(s) with your findings and please give them a working leaking sample/script. That will help them identify the issue faster and apply a patch almost instantly compared to "hey your plugin has a memory leak".

Also just out of curiosity, if you kick all the players before a gmx, does the ram usage drop significantly?

Edit: Ahw denNorske you fucked up my 1337 rep

someone please reset my rep to 1337
I realised just after giving you a rep that I did - I feel bad about dat ! (I wish I could just take the rep back)


And nope, kicking players doesn't free the memory. Ram always increase, and does never go down according to graphs. It's a slower growth when there are fewer players online.

And lets say this could be the MYSQL plugin, how could i test all the code I have in my gamemode? There are quite some functionality related to it, as it's a bit of it everywhere.
Also - I went through my commits and found that MySQL and Streamer are the only ones that has been Changed or added functions for. (Either added objects, or added new queries)
Reply
#10

Quote:
Originally Posted by denNorske
Посмотреть сообщение
I realised just after giving you a rep that I did - I feel bad about dat ! (I wish I could just take the rep back)


And nope, kicking players doesn't free the memory. Ram always increase, and does never go down according to graphs. It's a slower growth when there are fewer players online.

And lets say this could be the MYSQL plugin, how could i test all the code I have in my gamemode? There are quite some functionality related to it, as it's a bit of it everywhere.
Also - I went through my commits and found that MySQL and Streamer are the only ones that has been Changed or added functions for. (Either added objects, or added new queries)
If you are using MySql R33+ (the one with cache) its quite possible that you are causing leak by not freeing that same cache (results).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)