0

As the title says, I'm using Wt to build a forum. It is supposed to be part of a greater project (and in the meantime it gives me the opportunity to learn Wt better, before moving to the hardest part of the project).

The problem is that when I run the server, it requires around 1.5GB.

I'm not using at the moment images, media or other options. Only the "normal" (meaning html+text+javascript) widgets, combining them to create more complex widgets, the DBO and a lot of templates.

Does such an use of memory sound as normal for a WT application? If not, there is a way to profile the memory usage by functions, data structures and code (with percentages and so on, like we can do with time profiler)?

Apparently, according to Valgrind, I've no leaks.

==13061== Memcheck, a memory error detector
==13061== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==13061== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==13061== Command: ./GameServer --docroot=. --http-address 0.0.0.0 --http-port 8080
==13061== Parent PID: 13060
==13061==
==13061==
==13061== HEAP SUMMARY:
==13061== in use at exit: 111,172 bytes in 243 blocks
==13061== total heap usage: 271,492 allocs, 271,249 frees, 1,545,796,300 bytes allocated
==13061==
==13061== LEAK SUMMARY:
==13061== definitely lost: 0 bytes in 0 blocks
==13061== indirectly lost: 0 bytes in 0 blocks
==13061== possibly lost: 0 bytes in 0 blocks
==13061== still reachable: 109,820 bytes in 225 blocks
==13061== of which reachable via heuristic:
==13061== newarray : 1,536 bytes in 16 blocks
==13061== suppressed: 1,352 bytes in 18 blocks
==13061== Reachable blocks (those to which a pointer was found) are not shown.
==13061== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==13061==
==13061== For counts of detected and suppressed errors, rerun with: -v
==13061== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 18 from 18)

Edit: to reply to the question of Hayt: it does start with that much usage. While, indeed I make full and wide use of containers to momentarily save data (from DB queries, for example, but nothing that can justify so much memory, since the whole DB file at the moment is only 80kb), the usage of memory doesn't increase with time and the increase with a second user is negligible (System monitor confirms 1.4GB at the strart, after I refreshed several times the web page from user_1 and after I logged in with user_2).

Edit2: using valgrind with the massif tool, I found the problem: it was another part of the application totally unrelated to WT.

DrHell
  • 461
  • 3
  • 17
  • while valgrind detects leaks it may also be possible that you have some lists or containers you just never clear. Does it start with that much usage or does it accumulate over time? – Hayt Nov 02 '16 at 11:50
  • @Hayt: yes, it does start that way and there isn't an increment in memory usage with normal activity or from logging in a second user. I've edited the original question to add this. – DrHell Nov 02 '16 at 12:07
  • 1
    You can check where the memory comes from. I don't know WT but maybe this helps you diagnose better where the memory comes from: http://stackoverflow.com/questions/30512000/how-to-make-valgrind-log-all-allocations – Hayt Nov 02 '16 at 12:13
  • @Hayt: thanks, it worked like a charm and I found the reason of the abnormal memory usage. And the reason, just for the record, is that, of course, I'm an idiot: indeed the memory usage is not from the webserver in itself, but from another part of the project which was supposed to be included later, and that for some reason (probably to test it) I included earlier... then forgetting about it up to yesterday, when I noticed the disk swapping and went to check the memory usage. I'm going to edit the question and mark it as solved. Thanks again. – DrHell Nov 02 '16 at 12:35

1 Answers1

1

Ok, the problem was unrelated to WT. As suggested by Hayt in the comments, I used valgrind with the massif option, making a little .sh file (I'm using Ubuntu) with this line:

valgrind --tool=massif --trace-children=yes --num-callers=500 --log-file=massif.txt ./WebServer --docroot=. --http-address 0.0.0.0 --http-port 8080

Where "WebServer" is the name of the application and the options following it are specific to wt servers, and the problem was caused by another part of the project, which I forgot I included till the moment when I noticed the memory swap.

Solved.

DrHell
  • 461
  • 3
  • 17