jump to navigation

Server Test Results August 11, 2010

Posted by aknartrebna in Uncategorized.
add a comment

Yesterday, on looking at some of the Valgrind output, I discovered that I had a few memory leaks in the code.  I was freeing what I was supposed to, however it was inside an if statement, so I just added an else at the end of each if statement to run mysql_free_result().  So I ran my login/out iterator, and here are the results:

==10813==
==10813== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 48 from 3)
==10813== malloc/free: in use at exit: 86,275 bytes in 25 blocks.
==10813== malloc/free: 39,991,979 allocs, 39,991,954 frees, 119,153,575,663 bytes allocated.
==10813== For counts of detected errors, rerun with: -v
==10813== searching for pointers to 25 not-freed blocks.
==10813== checked 678,324 bytes.
==10813==
==10813==
==10813== 28 bytes in 1 blocks are still reachable in loss record 1 of 3
==10813==    at 0x4023D6E: malloc (vg_replace_malloc.c:207)
==10813==    by 0x400C355: (within /lib/ld-2.7.so)
==10813==    by 0x4011BA6: (within /lib/ld-2.7.so)
==10813==    by 0x400DA15: (within /lib/ld-2.7.so)
==10813==    by 0x401154D: (within /lib/ld-2.7.so)
==10813==    by 0x4466131: (within /lib/i686/cmov/libc-2.7.so)
==10813==    by 0x400DA15: (within /lib/ld-2.7.so)
==10813==    by 0x44662F4: __libc_dlopen_mode (in /lib/i686/cmov/libc-2.7.so)
==10813==    by 0x44B4DC6: pthread_cancel_init (in /lib/i686/cmov/libpthread-2.7.so)
==10813==    by 0x44B4EF0: _Unwind_ForcedUnwind (in /lib/i686/cmov/libpthread-2.7.so)
==10813==    by 0x44B2900: __pthread_unwind (in /lib/i686/cmov/libpthread-2.7.so)
==10813==    by 0x44ACA1F: pthread_exit (in /lib/i686/cmov/libpthread-2.7.so)
==10813==
==10813==
==10813== 24,927 bytes in 9 blocks are still reachable in loss record 2 of 3
==10813==    at 0x4023D6E: malloc (vg_replace_malloc.c:207)
==10813==    by 0x40890DC: my_malloc (in /usr/lib/libmysqlclient.so.15.0.0)
==10813==    by 0x4089E2A: my_error_register (in /usr/lib/libmysqlclient.so.15.0.0)
==10813==    by 0x4088D0F: init_client_errs (in /usr/lib/libmysqlclient.so.15.0.0)
==10813==    by 0x40879C8: mysql_server_init (in /usr/lib/libmysqlclient.so.15.0.0)
==10813==    by 0x40AEFF9: mysql_init (in /usr/lib/libmysqlclient.so.15.0.0)
==10813==    by 0x804A42F: main (bfoc_server.cpp:131)
==10813==
==10813==
==10813== 61,320 bytes in 15 blocks are still reachable in loss record 3 of 3
==10813==    at 0x4023D6E: malloc (vg_replace_malloc.c:207)
==10813==    by 0x4090142: my_once_alloc (in /usr/lib/libmysqlclient.so.15.0.0)
==10813==    by 0x40907DA: (within /usr/lib/libmysqlclient.so.15.0.0)
==10813==    by 0x4091169: (within /usr/lib/libmysqlclient.so.15.0.0)
==10813==    by 0x4091486: get_charset_by_csname (in /usr/lib/libmysqlclient.so.15.0.0)
==10813==    by 0x40AEDD1: mysql_init_character_set (in /usr/lib/libmysqlclient.so.15.0.0)
==10813==    by 0x40B0DA2: mysql_real_connect (in /usr/lib/libmysqlclient.so.15.0.0)
==10813==    by 0x804A473: main (bfoc_server.cpp:134)
==10813==
==10813== LEAK SUMMARY:
==10813==    definitely lost: 0 bytes in 0 blocks.
==10813==      possibly lost: 0 bytes in 0 blocks.
==10813==    still reachable: 86,275 bytes in 25 blocks.
==10813==         suppressed: 0 bytes in 0 blocks.

real    1310m14.214s
user    16m29.950s
sys    5m45.234s

The first memory leak is prolly because instead of exiting the program properly I hit Ctrl+C; the other two are from initializing and connecting to the msyql database — which occurrs in mysql.h. I would fret over this, however it only happens once during the programs running.

25 un-free’d blocks out of almost 40 million allocs/frees is about as good as it gets 🙂  I shouldn’t have to reset the server every day or so now either, nor will I have to worry about it running on only 512MB ram.  Huzzah!

Explanation of memory leaks:  In the C family of languages, you are allowed to access your computer’s memory directly.  So, when you need a non-constant amount of memory for something like a string or a variable amount of data, you have to allocate (or in programmer’s speak, alloc) that amount of memory in order to use with the malloc() function.  When you are done, it has to be freed with the function free().  Un-free’d memory is referred to as a memory leak.  If you get to many, you can potentially run out of memory or at the very minimum take up more space in memory than what is needed, potentially slowing the computer down.  Memory leaks can easily become A Bad Thing.

Character Models loaded :) August 10, 2010

Posted by aknartrebna in Uncategorized.
add a comment

Just a quick update, won’t take long.

Last week I was able to get the character model loader to work.  I now have a textured cube that moves up and down on the screen while moving from side to side.  The up and down is done in the program and side-to-side is done via animation set in Blender.  This may not sound like much, but it’s the framework for how a real character model will walk across the screen.

Currently, I’m still in a programming mood not an art mood so I’m coding some more.  Right now I’m working on NAT traversal (i.e. getting through routers) while continuing with the code designing and figuring out how to code up the battles while keeping units from “running over” each other.  As far as big hurdles go I believe these are some of the last.  I’m also still trying to get my thoughs straight on how to do unit production, i.e. where to place the buildings (either on the map or across the bottom of the screen).

Other things that are finalized:

Formation editor — will be a grid where players can drag and drop units to make formations and launch them towards the enemy.

Design — all units will be a part of a polymorphic class (of course).  Simple designs are better, and Object Oriented approaches make that happen.  The rest of the design and details haven’t been ironed out, but that one is definite.

In Progress:

Client-side networking — NAT punch-through (being worked on now, will use UDP protocol with an encryption scheme).

Attack & movement algorithm — designing the data structures to handle attacking and makeing sure collisions do not happen.

GUI design — kinda decided on, but then again maybe not…

For more updates, follow me on twitter! @aknartrebna or look for/use the hashtag #bfoc.

Progress Update and Race Outline August 4, 2010

Posted by aknartrebna in Uncategorized.
add a comment

Good news!  I have the models loaded on the screen now! w00t! …only the model is a cube that moves from side to side, but that’s a solid beginning.  I shall do a little more work to the rocket walker and finish drawing the basic Pelladian soon.  However, I’m not working on that today since I’m in a programming mood and am now in a designing mood so I’m taking advantage of it and laying out the classes for the program.  When I get it finished/finalized, I’ll post it on here for all to see.  I also have made good progress with designing the military units.  I’m going for the different races = different ways to play strategy, where each race has different pros and cons that will be balanced out so that no race is stronger than the other.  Here are the races:

Crinikian — Very technological, but not big on science. The Crinikian forces rely on robots and projectile weapons with good armor piloted by soldiers with excellent instincts for operating machines.  There are a few Crinikiians that have mastered science and make the weapons for the military to use, which range from grenades, rockets, heavy shells, mines, and perhaps a nuke or two.

Arkonite — Many believe they have magical powers, but some thing they are just scientifically advanced — no one knows for sure as they are very secretive with their “magic” devices that can do significant damage to any enemy.  They also carry “magic” shields that can regain strength after taking damage.  There is also a pyrotechnic side to the Arkonites; they can “summon” a “fire” that can stick to the enemy and can’t be doused.

Pelladian — These alien lifeforms and uninvited guests on Planet Crinikii bring some weaponry never before seen in the known universe.  Their solid black shells and glowing eyes might be fearsome enough, but coupled with their psionic weaponry and the ability to make someone melt from inside out is enough to make anyone run for the hills.