How to release resources used by GSettings? - glib

I'm trying to write application in C which manipulates GSettings. Unfortunately I have encountered some kind of memory leaks so I tried to track them down. I'm not sure whether this is library bug or am I missing something. This is the smallest example I come up with that allocates memory till it crashes.
#include <glib.h>
#include <gio/gio.h>
int main() {
while (1) {
GSettings *settings = g_settings_new("com.linuxmint.updates");
g_object_unref(settings);
//g_clear_object(&settings); // This leaks as well but seems to leak "slower"
}
return 0;
}
Can anyone explain me why memory leaks in this example and how to fix it?
PS I'm using libglib-2.0 (version 2.56.3 which come with Ubuntu 18.04 LTS / Mint).
EDIT 1
As per request in comments I'm posting valgrind output. I'm using command: valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=50 --show-leak-kinds=definite ./main. I have changed program a little to be finite (it looping while 100.000 times). Here is output for that changed parameter.
==16375== Memcheck, a memory error detector
==16375== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==16375== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==16375== Command: ./main
==16375==
==16375==
==16375== HEAP SUMMARY:
==16375== in use at exit: 297,081,397 bytes in 5,056,358 blocks
==16375== total heap usage: 26,147,615 allocs, 21,091,257 frees, 1,064,178,170 bytes allocated
==16375==
==16375== LEAK SUMMARY:
==16375== definitely lost: 0 bytes in 0 blocks
==16375== indirectly lost: 0 bytes in 0 blocks
==16375== possibly lost: 2,840 bytes in 27 blocks
==16375== still reachable: 297,066,261 bytes in 5,056,238 blocks
==16375== of which reachable via heuristic:
==16375== length64 : 1,384 bytes in 28 blocks
==16375== newarray : 1,808 bytes in 33 blocks
==16375== suppressed: 0 bytes in 0 blocks
==16375== Reachable blocks (those to which a pointer was found) are not shown.
==16375== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==16375==
==16375== For counts of detected and suppressed errors, rerun with: -v
==16375== ERROR SUMMARY: 27 errors from 27 contexts (suppressed: 0 from 0)
I'm not an expert but parameter still reachable grows with number of loop. How those objects (or rather structures) can be reached if I'm consistently using one variable? Am I missing something? I'm trying do what is advised here: https://developer.gnome.org/gobject/stable/gobject-memory.html
EDIT 2
I was digging deeper into this problem. Because I was unsure that my code actually is correct I decided to change it to another GObject like this:
#include <glib.h>
#include <gio/gio.h>
int main() {
while (1) {
GFile *file = g_file_new_for_path ("/path/to/some/file");
g_object_unref(file);
//g_clear_object(&settings);
}
return 0;
}
I'm aware this do not open any file and only creates handle to resource but this code have constant memory usage over time. If I remove unref then it obviously leaks and crashes.
This is how valgrind output looks for this snippet for 100.000 and 1.000.000 iterations.
iterations = 100.000
==13257== Memcheck, a memory error detector
==13257== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==13257== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==13257== Command: ./main
==13257==
==13257==
==13257== HEAP SUMMARY:
==13257== in use at exit: 159,435 bytes in 1,975 blocks
==13257== total heap usage: 205,209 allocs, 203,234 frees, 6,758,893 bytes allocated
==13257==
==13257== LEAK SUMMARY:
==13257== definitely lost: 0 bytes in 0 blocks
==13257== indirectly lost: 0 bytes in 0 blocks
==13257== possibly lost: 2,528 bytes in 26 blocks
==13257== still reachable: 144,699 bytes in 1,852 blocks
==13257== of which reachable via heuristic:
==13257== length64 : 1,688 bytes in 32 blocks
==13257== newarray : 1,840 bytes in 35 blocks
==13257== suppressed: 0 bytes in 0 blocks
==13257== Rerun with --leak-check=full to see details of leaked memory
==13257==
==13257== For counts of detected and suppressed errors, rerun with: -v
==13257== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
iterations = 1.000.000
==12440== Memcheck, a memory error detector
==12440== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==12440== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==12440== Command: ./main
==12440==
==12440==
==12440== HEAP SUMMARY:
==12440== in use at exit: 157,241 bytes in 1,936 blocks
==12440== total heap usage: 2,005,339 allocs, 2,003,403 frees, 64,363,746 bytes allocated
==12440==
==12440== LEAK SUMMARY:
==12440== definitely lost: 0 bytes in 0 blocks
==12440== indirectly lost: 0 bytes in 0 blocks
==12440== possibly lost: 2,528 bytes in 26 blocks
==12440== still reachable: 142,505 bytes in 1,813 blocks
==12440== of which reachable via heuristic:
==12440== length64 : 1,688 bytes in 32 blocks
==12440== newarray : 1,840 bytes in 35 blocks
==12440== suppressed: 0 bytes in 0 blocks
==12440== Rerun with --leak-check=full to see details of leaked memory
==12440==
==12440== For counts of detected and suppressed errors, rerun with: -v
==12440== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
This gives me some idea that second code have almost same number allocations vs frees (diffrence is in both cases < 2000 which are probably some static allocations for lifetime of library).
This is not the case in first snippet where I use GSettings object. Number of allocations vs frees is nowhere constant and it grows over time.
I will try running this program against latest glib when I'll have access to some rolling release distro (arch probably) because I think compiling latest glib and plug it into Ubuntu is too complicated to me.

This ‘leak’ of reachable memory is an artifact of your test program. Each time you construct a GSettings object, it needs to add some match rules to the D-Bus session bus so that it can receive signals from the dconf daemon. Adding a match rule means sending a D-Bus method call to the message bus daemon and then waiting for a reply.
By creating 100000 GSettings objects in a row, you are queueing up 100000 AddMatch calls to the message bus daemon, including 100000 allocations containing information about the pending method call replies. However, your program exits before the message bus daemon replies to the majority of the AddMatch calls; so a lot of those allocations detailing the pending replies are still allocated on exit.
If your program were to sleep for, say, a minute until the message bus daemon had replied to all the AddMatch calls, I would expect that the ‘still reachable’ allocations would be consistent with the GFile example you ran.
(Note that it’s OK to do a usleep() call in your main() function to demonstrate this, as the D-Bus method calls and replies are handled in a separate worker thread.)

Related

understanding docker container cpu usages

docker stats shows that the cpu usage to be very high. But top command out shows that 88.3% cpu is not being used. Inside the container is a java service httpthrift service.
docker stats :
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
8a0488xxxx5 540.9% 41.99 GiB / 44 GiB 95.43% 0 B / 0 B 0 B / 35.2 MB 286
top output :
top - 07:56:58 up 2 days, 22:29, 0 users, load average: 2.88, 3.01, 3.05
Tasks: 13 total, 1 running, 12 sleeping, 0 stopped, 0 zombie
%Cpu(s): 8.2 us, 2.7 sy, 0.0 ni, 88.3 id, 0.0 wa, 0.0 hi, 0.9 si, 0.0 st
KiB Mem: 65959920 total, 47983628 used, 17976292 free, 357632 buffers
KiB Swap: 7999484 total, 0 used, 7999484 free. 2788868 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8823 root 20 0 58.950g 0.041t 21080 S 540.9 66.5 16716:32 java
How to reduce the cpu usage and bring it under 100%?
According to the top man page:
When operating in Solaris mode (`I' toggled Off), a task's cpu usage will be divided by the total number of CPUs. After issuing this command, you'll be told the new state of this toggle.
So by pressing the key I when using top in interactive mode, you will switch to the Solaris mode and the CPU usage will be divided by the total number of CPUs (or cores).
P.S.: This option is not available on all versions of top.

When Cassandra is running almost all RAM is consumed, why?

I have CentOS 6.8, Cassandra 3.9, 32 GB RAM. When I start Cassandra and once it is started, it starts consuming the memory and start adding up 'Cached' memory value when I start querying from CQLSH or Apache Spark and in this process, very less memory remain for other processing like cron execution.
Here are some details from my system
free -m
total used free shared buffers cached
Mem: 32240 32003 237 0 41 24010
-/+ buffers/cache: 7950 24290
Swap: 2047 25 2022
And here is the output of top -M command
top - 08:54:39 up 5 days, 16:24, 4 users, load average: 1.22, 1.20, 1.29
Tasks: 205 total, 2 running, 203 sleeping, 0 stopped, 0 zombie
Cpu(s): 3.5%us, 1.2%sy, 19.8%ni, 75.3%id, 0.1%wa, 0.1%hi, 0.0%si, 0.0%st
Mem: 31.485G total, 31.271G used, 219.410M free, 42.289M buffers
Swap: 2047.996M total, 25.867M used, 2022.129M free, 23.461G cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
14313 cassandr 20 0 595g 28g 22g S 144.5 91.3 300:56.34 java
You can see only 220 MB is left and 23.46 is cached.
My question is how to configure Cassandra so that it can use 'cached' memory to certain value and leave more RAM available for other processes.
Thanks in advance.
In linux in general cached memory as your 23g is just really fine. This memory is used as filesystem cache and so on - not by cassandra itself. Linux systems tend to use all available memory.
This helps to speed up your system in many ways to prevent disk reads.
You can still use the cached memory - just start processes and use your ram, the kernel will free it immediatly.
You can set the sizes in cassandra-env.sh under conf folder. This article should help. http://docs.datastax.com/en/cassandra/3.0/cassandra/operations/opsTuneJVM.html

how to convert hex format rsa private key to PKCS8 format in iOS

I need to use a private key to do RSA Signing.
The company gave me the private key like this:
3082025C02010002818100AB13EC000380B4E489F717440D42473BD1C0F0B4F36D765171B3868ADF1CCAA782B48C71560C48342DFAEA01C6DBAF7A36F885B58BB24D7934352AA304941B1EB8373B561C4FBF11181C2E75ED3356CAE5B0DC9759A42CE997F5E5321AA5A67C5A2AE923F4705E61C2C7C8C2441CDCE6DE8638AB9294DA7A9A5B59E2E31C8A9B0203010001028180037ECDB4965DBBD46B8933DD7D13DC96B94B62DF9F959DF43E0977F74065BB323EF667642D68E4D4C417BB4E3BFCE311F12B94B7C7D9E5C15332BEE343C5AEE4223BF3ADE524C2726A685E62938C6B62ADA73529C762A61ABF707E936CFAC2233AD2C7DB0D8764194A7648C16A85FA54E0EBA32BFAB616CBE0009E5E3B8B5349024100D463E0012A09AA1399B5AD6BDDB47A7418F35109786899DDE1913647D3864A7897747D001122E3430CA58F4E94391208E9059606AEA8389E045B31273EBD2C75024100CE347F1CF65ACEFB6B21B758D7AB6B850F4BA1ECFC7DA1B0FC52538AF5D5280393ADB06D0A0762E66526C5755ABC6F81C22A6463E8B0E27D69BDEFFA8F3C38CF024100A10054FE8CEF668E1527339F61213EF263378F66AE701CB3A61A7E1B54ADA82662295BD88125014202843E6E42CE406DA0B72B5345731FF8293537BD9841AF410240472BDF63C3B3FC14D319440B2A05448B1C88624F45A6A7144B42AF0B1B6682F51917ADF934A8EFFDCD93E03B6D21F4EAB875A148CA9BA2D0DE9A6C25F3223A0902401E673CB216C11DCCD41D99F4892C2027A03ADE42E64C7B4410BF9C4D1B0A58C51CF33FA3BA1D8F4D693A2C5CCB0D42A4A787EE32729871FEF4FC143DFFA170A2
It's in a hex format, but OpenSSL's PEM_read_bio_RSAPrivateKey() function returns NULL. I searched for help about this and found out the private key must be in "PKCS8" format. So how can I convert the hex format above to PKCS8 format in my code?
The following uses OpenSSL 1.1.0 (I needed to do some other testing). It also uses d2i_RSAPrivateKey rather than PEM_read_bio_RSAPrivateKey. The key is in ASN.1/DER, so you can't use the PEM routines.
Compile and link with something similar to gcc -I/usr/local/ssl/1.1.0/include test.cc -o test.exe /usr/local/ssl/1.1.0/lib/libcrypto.a.
You should also add code to cleanup the library. Also see Library Initialization on the OpenSSL wiki.
#include <stdio.h>
#include <unistd.h>
#include <openssl/opensslconf.h>
#include <openssl/crypto.h>
#include <openssl/rsa.h>
const char encoded[] =
"3082025C02010002818100AB13EC000380B4E489F717440D42473BD1C0"
"F0B4F36D765171B3868ADF1CCAA782B48C71560C48342DFAEA01C6DBAF"
"7A36F885B58BB24D7934352AA304941B1EB8373B561C4FBF11181C2E75"
"ED3356CAE5B0DC9759A42CE997F5E5321AA5A67C5A2AE923F4705E61C2"
"C7C8C2441CDCE6DE8638AB9294DA7A9A5B59E2E31C8A9B020301000102"
"8180037ECDB4965DBBD46B8933DD7D13DC96B94B62DF9F959DF43E0977"
"F74065BB323EF667642D68E4D4C417BB4E3BFCE311F12B94B7C7D9E5C1"
"5332BEE343C5AEE4223BF3ADE524C2726A685E62938C6B62ADA73529C7"
"62A61ABF707E936CFAC2233AD2C7DB0D8764194A7648C16A85FA54E0EB"
"A32BFAB616CBE0009E5E3B8B5349024100D463E0012A09AA1399B5AD6B"
"DDB47A7418F35109786899DDE1913647D3864A7897747D001122E3430C"
"A58F4E94391208E9059606AEA8389E045B31273EBD2C75024100CE347F"
"1CF65ACEFB6B21B758D7AB6B850F4BA1ECFC7DA1B0FC52538AF5D52803"
"93ADB06D0A0762E66526C5755ABC6F81C22A6463E8B0E27D69BDEFFA8F"
"3C38CF024100A10054FE8CEF668E1527339F61213EF263378F66AE701C"
"B3A61A7E1B54ADA82662295BD88125014202843E6E42CE406DA0B72B53"
"45731FF8293537BD9841AF410240472BDF63C3B3FC14D319440B2A0544"
"8B1C88624F45A6A7144B42AF0B1B6682F51917ADF934A8EFFDCD93E03B"
"6D21F4EAB875A148CA9BA2D0DE9A6C25F3223A0902401E673CB216C11D"
"CCD41D99F4892C2027A03ADE42E64C7B4410BF9C4D1B0A58C51CF33FA3"
"BA1D8F4D693A2C5CCB0D42A4A787EE32729871FEF4FC143DFFA170A2";
int main(int argc, char* argv[])
{
long length = 0;
unsigned char* decoded = NULL;
RSA* rsa = NULL;
decoded = OPENSSL_hexstr2buf(encoded, &length);
if (decoded == NULL || length == 0)
return 1;
const unsigned char* temp = decoded;
rsa = d2i_RSAPrivateKey(NULL, &temp, length);
if (rsa == NULL)
return 1;
RSA_print_fp(stdout, rsa, 0);
if (rsa)
RSA_free(rsa);
if (decoded)
OPENSSL_free(decoded);
return 0;
}
const unsigned char* temp = decoded is used because temp is temporary, and d2i_RSAPrivateKey increments the pointer to the next private key (if another parse will be attempted). You can still get to the original data through decoded.
It results in:
$ ./test.exe
Private-Key: (1024 bit)
modulus:
00:ab:13:ec:00:03:80:b4:e4:89:f7:17:44:0d:42:
47:3b:d1:c0:f0:b4:f3:6d:76:51:71:b3:86:8a:df:
1c:ca:a7:82:b4:8c:71:56:0c:48:34:2d:fa:ea:01:
c6:db:af:7a:36:f8:85:b5:8b:b2:4d:79:34:35:2a:
a3:04:94:1b:1e:b8:37:3b:56:1c:4f:bf:11:18:1c:
2e:75:ed:33:56:ca:e5:b0:dc:97:59:a4:2c:e9:97:
f5:e5:32:1a:a5:a6:7c:5a:2a:e9:23:f4:70:5e:61:
c2:c7:c8:c2:44:1c:dc:e6:de:86:38:ab:92:94:da:
7a:9a:5b:59:e2:e3:1c:8a:9b
publicExponent: 65537 (0x10001)
privateExponent:
03:7e:cd:b4:96:5d:bb:d4:6b:89:33:dd:7d:13:dc:
96:b9:4b:62:df:9f:95:9d:f4:3e:09:77:f7:40:65:
bb:32:3e:f6:67:64:2d:68:e4:d4:c4:17:bb:4e:3b:
fc:e3:11:f1:2b:94:b7:c7:d9:e5:c1:53:32:be:e3:
43:c5:ae:e4:22:3b:f3:ad:e5:24:c2:72:6a:68:5e:
62:93:8c:6b:62:ad:a7:35:29:c7:62:a6:1a:bf:70:
7e:93:6c:fa:c2:23:3a:d2:c7:db:0d:87:64:19:4a:
76:48:c1:6a:85:fa:54:e0:eb:a3:2b:fa:b6:16:cb:
e0:00:9e:5e:3b:8b:53:49
prime1:
00:d4:63:e0:01:2a:09:aa:13:99:b5:ad:6b:dd:b4:
7a:74:18:f3:51:09:78:68:99:dd:e1:91:36:47:d3:
86:4a:78:97:74:7d:00:11:22:e3:43:0c:a5:8f:4e:
94:39:12:08:e9:05:96:06:ae:a8:38:9e:04:5b:31:
27:3e:bd:2c:75
prime2:
00:ce:34:7f:1c:f6:5a:ce:fb:6b:21:b7:58:d7:ab:
6b:85:0f:4b:a1:ec:fc:7d:a1:b0:fc:52:53:8a:f5:
d5:28:03:93:ad:b0:6d:0a:07:62:e6:65:26:c5:75:
5a:bc:6f:81:c2:2a:64:63:e8:b0:e2:7d:69:bd:ef:
fa:8f:3c:38:cf
exponent1:
00:a1:00:54:fe:8c:ef:66:8e:15:27:33:9f:61:21:
3e:f2:63:37:8f:66:ae:70:1c:b3:a6:1a:7e:1b:54:
ad:a8:26:62:29:5b:d8:81:25:01:42:02:84:3e:6e:
42:ce:40:6d:a0:b7:2b:53:45:73:1f:f8:29:35:37:
bd:98:41:af:41
exponent2:
47:2b:df:63:c3:b3:fc:14:d3:19:44:0b:2a:05:44:
8b:1c:88:62:4f:45:a6:a7:14:4b:42:af:0b:1b:66:
82:f5:19:17:ad:f9:34:a8:ef:fd:cd:93:e0:3b:6d:
21:f4:ea:b8:75:a1:48:ca:9b:a2:d0:de:9a:6c:25:
f3:22:3a:09
coefficient:
1e:67:3c:b2:16:c1:1d:cc:d4:1d:99:f4:89:2c:20:
27:a0:3a:de:42:e6:4c:7b:44:10:bf:9c:4d:1b:0a:
58:c5:1c:f3:3f:a3:ba:1d:8f:4d:69:3a:2c:5c:cb:
0d:42:a4:a7:87:ee:32:72:98:71:fe:f4:fc:14:3d:
ff:a1:70:a2
If you don't cleanup, then Valgrind will report something like:
$ valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./test.exe
==32773== Memcheck, a memory error detector
==32773== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==32773== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==32773== Command: ./test.exe
==32773==
...
==32773==
==32773== HEAP SUMMARY:
==32773== in use at exit: 63,005 bytes in 365 blocks
==32773== total heap usage: 547 allocs, 182 frees, 69,806 bytes allocated
==32773==
==32773== 200 bytes in 1 blocks are still reachable in loss record 55 of 83
==32773== at 0x4D11: malloc (vg_replace_malloc.c:303)
==32773== by 0x10010AA3E: CRYPTO_zalloc (in ./test.exe)
==32773== by 0x1001522BB: CRYPTO_THREAD_lock_new (in ./test.exe)
==32773== by 0x100104EC8: do_ex_data_init (in ./test.exe)
==32773== by 0xD8FBF: pthread_once (in /usr/lib/system/libsystem_c.dylib)
==32773== by 0x1001523A8: CRYPTO_THREAD_run_once (in ./test.exe)
==32773== by 0x100104768: CRYPTO_new_ex_data (in ./test.exe)
==32773== by 0x10012A9C3: RSA_new_method (in ./test.exe)
==32773== by 0x100129ED1: rsa_cb (in ./test.exe)
==32773== by 0x100027057: asn1_item_embed_new (in ./test.exe)
==32773== by 0x1000244CA: asn1_item_embed_d2i (in ./test.exe)
==32773== by 0x100024125: ASN1_item_d2i (in ./test.exe)
==32773==
==32773== 4,096 bytes in 1 blocks are still reachable in loss record 81 of 83
==32773== at 0x4D11: malloc (vg_replace_malloc.c:303)
==32773== by 0x1431D8: __smakebuf (in /usr/lib/system/libsystem_c.dylib)
==32773== by 0x104F34: __swsetup (in /usr/lib/system/libsystem_c.dylib)
==32773== by 0x142392: __sfvwrite (in /usr/lib/system/libsystem_c.dylib)
==32773== by 0x142994: fwrite (in /usr/lib/system/libsystem_c.dylib)
==32773== by 0x100031997: file_write (in ./test.exe)
==32773== by 0x100030A29: BIO_write (in ./test.exe)
==32773== by 0x10002CFFB: BIO_vprintf (in ./test.exe)
==32773== by 0x10002CEFC: BIO_printf (in ./test.exe)
==32773== by 0x100129B7C: do_rsa_print (in ./test.exe)
==32773== by 0x10012EDBC: RSA_print_fp (in ./test.exe)
==32773== by 0x1000010C4: main (test.cc:48)
==32773==
==32773== LEAK SUMMARY:
==32773== definitely lost: 0 bytes in 0 blocks
==32773== indirectly lost: 0 bytes in 0 blocks
==32773== possibly lost: 0 bytes in 0 blocks
==32773== still reachable: 4,296 bytes in 2 blocks
==32773== suppressed: 58,709 bytes in 363 blocks
==32773==

How do I pump traffic using tcpreplay at 100 MBps, 500 MBps and 1Gbps speeds?

I used the -R and -K option but it doesnt seem to be working as I captured the pumped traffic using tcpdump and the number of packets that I see there dont seem to match the number of packets that I expect in the time frame.
First of all make sure you are using the latest version, available here. You will want to use the -K and --mbps (or -M) options, for example:
# tcpreplay -i eth7 -K --mbps 1000 smallFlows.pcap
File Cache is enabled
Actual: 14261 packets (9216531 bytes) sent in 0.073761 seconds.
Rated: 124951275.0 Bps, 999.61 Mbps, 193340.65 pps
Flows: 1209 flows, 16390.77 fps, 14243 flow packets, 18 non-flow
Statistics for network device: eth7
Attempted packets: 14261
Successful packets: 14261
Failed packets: 0
Truncated packets: 0
Retried packets (ENOBUFS): 0
Retried packets (EAGAIN): 0
When you attempt to move to higher speeds (e.g. 10GigE) you may need to generate a bigger block of data by using the --loop option. Also with Tcpreplay version 4.0 there are the more advanced --netmap and --unique-ip options which on a properly set up system, will achieve near wire rate and very high flows/sec. More information available at Tcpreplay How To. Here is an example:
# tcpreplay -i eth7 -K --mbps 9500 --loop 100 --netmap --unique-ip smallFlows.pcap
Switching network driver for eth7 to netmap bypass mode... done!
File Cache is enabled
Actual: 1426100 packets (921653100 bytes) sent in 0.776133 seconds.
Rated: 1187493767.1 Bps, 9499.95 Mbps, 1837442.80 pps
Flows: 120900 flows, 155772.27 fps, 1424300 flow packets, 1800 non-flow
Statistics for network device: eth7
Attempted packets: 1426100
Successful packets: 1426100
Failed packets: 0
Truncated packets: 0
Retried packets (ENOBUFS): 0
Retried packets (EAGAIN): 0
Switching network driver for eth7 to normal mode... done!

Memory usage on Debian Linux

I am trying to figure out what is wrong with my Debian server - I am getting warnings of having not enough free memory - top (as you can see below) is saying that 1.8G is consumed, but I am unable to find which application is responsible for it. There is only Tomcat running, which consumes, according to top, ~25 % and so 530m. But There is more than 1 GB left, which I am unable to find!
Tasks: 54 total, 1 running, 53 sleeping, 0 stopped, 0 zombie
Cpu(s):100.0%us, 0.0%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 2150400k total, 1877728k used, 272672k free, 0k buffers
Swap: 0k total, 0k used, 0k free, 0k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
3271 root 18 0 1559m 530m 12m S 0 25.2 1:44.31 java
1568 mysql 15 0 270m 71m 7332 S 0 3.4 0:50.79 mysqld
(Full top output here)
Linux systems always try to use as much ram as available for various functions like caching of executables our even just page reads from disk. That's what you bought your fast RAM for after all.
You can find out more about your system by doing a
cat /proc/meminfo
More info in this helpful blog post
If you find out a lot is used in cache then you don't have to worry about the system.if individual processes warn you about memory issues then you'll have to check their settings for any memory limiting settings. Many server processes have those, like php or java based processes.
Questions of this nature are also probably more at home at https://serverfault.com/
As i see, your 'Free' command returned NO swap space
Swap: 0k total, 0k used, 0k free, 0k cached
either there is no swap partition available
this swap space is not mounted
one can manual make a swapfile
and mount this file as becoming the active swap
howto make swap
To test your real usage
reboot the machine and
test the used amount
retest after 1 hour
some processes are memory hoggs
like apache or ntop
refer:
check memory
display sorted
memory usage

Resources