Thursday, December 20, 2007

Memory Debugging with VC8

Want to check how many hundreds of memory leaks you have?

Using the microsofts CRT debug heap is an easy way of doing it.

To get a listing of all memory leaks, you simply need to include crtdbg.h, set the debug flag, using the function _CrtSetDbgFlag and run your code in debug mode. The leaks will appear in the output tab.

To get started with it here is the minimal code to implement it:

#include 
int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
flag |= _CRTDBG_LEAK_CHECK_DF; // Turn on leak-checking
_CrtSetDbgFlag(flag); // Set flag to the new value

To turn it off:
// Turn off CRT block checking bit
tmpFlag &= ~_CRTDBG_CHECK_CRT_DF;
This will only tell you how many leaks you have. To be really useful you want to know which calls to new are causing the memory leaks. In order for MSVC IDE to point to the lines of code which allocate the memory that causes the leak, simply redefine new as such:

#define new new(_NORMAL_BLOCK,__FILE__, __LINE_)

Finally if you get a memory leak you can set a breakpoint at a secific

Finally if you get a memory leak you can set a breakpoint at a specific allocation number by using:

_CrtSetBreakAlloc(2825);
with 2825 being the allocation nb shown in {} in the error message.

Et voila!
Simple no?

Tuesday, December 11, 2007

POCO and open-source


Recently I stumbled on POCO: A C++ Portable Components, or a collection of open source C++ class libraries. One word: wow. This library seems very well thought and having tried several libraries this one is the most promising.

Actually I am using mostly boost but I begin to be worried by the inconsistence between each sub libraries considering the api, the documentation and some over bloated code.
My principal need was a cross-platform threading libraries but boost::thread is lacking in some areas (no read-write mutex, difficulty to set thread specific code, ...). All those are present in POCO.

I will definitively switch to it if my tests are satisfactory and forget about boost. In fact I am even hoping that boost will not be used at all in the C++0x revision...


Marthen Mickos the MySQL CEO posted very interesting thoughts about how to succeed with an open-source project.
They needed 12 years... I will try to explain this to my wife:
"Darling! Let me work on my pet project... I will be rich in 12 years."
Somehow I have the feeling it will be difficult to convince her :)
MySQL needed 6 years to have a stable code so OGE has still 5 years to become stable.
Good - I am not as off track as I feared :D

Thursday, November 8, 2007

OGEd - Ogre/OGE editor

A week ago I began work on an oge/ogre editor.

As oge uses ogre resources such as .material, .mesh, etc this editor can also be used as a resources editor for Ogre3D.

Even after one week when the code is fairly minimal I already understand better the interdependences of the ogre resources and this will oblige me to make a small refactoring.

Discovering as you code new features or libraries complexities is one of the main reason that "linear project management" (aka Waterfall model : requirements -> analysis-> design -> coding -> testing -> installation) is possible only if you know extensively your environment. When dealing with a medium sized project or libraries you don't know in depth a "recursive project management" (aka Spiral model) is much preferable.

One book I must read is the second edition of Code Complete... one more TODO :)

Thursday, October 25, 2007

Nara Candle Festival

Le 20 c'est tenu le Nara Candle Festival. C'est un festival annuel sur le jumelage entre Canberra et Nara - l'ancienne capitale du Japon.

Le festival en lui-même se passe à la tombé de la nuit et rassemble - comme c'est surprenant - tous les japonais du coin, les traiteurs - miam - et autres groupes culturels japonais. Le spectacle de Kodo était fait par des blancs mais très bon (Kotori Trio). Il faudra que je trouve plus d'infos sur eux. Oliver a adoré la performance.

La fête était très sympa.

Ce qui me surprendra toujours c'est à quel point les australiens et japonais sont propres: le site de la fête n'est pas rempli de détritus comme en Europe.

Après le combat de sabre (en bois) les combattants ont donner les sabres au public! J'aurais adoré en avoir un... même si Adi l'aurait utilisé pour démolir la maison.

Dès qu'on trouve le temps on ira visiter le japon à nouveau et comme Nara se trouve près d'Osaka cette ville sera certainement du parcours.
http://www.japan-guide.com/e/e2165.html
http://upload.wikimedia.org/wikipedia/en/0/09/Nara856.jpg

Sunday, October 21, 2007

OGE shooting!


Our project OGE passed a critical milestone I can now create game, level and scene objects. Even if the code still needs some polishing before committing to cvs I were able to create a very basic fps. You can move, jump and shoot - what do you need more in a fps ? ;)

Wednesday, October 10, 2007

Khavi.org

L'autre jour je suis tombé sur le site de khavi.
Leur mission: "to gather and provide free electronic grooves".

Totalement gratuit les musiques qu'on peut télécharger sont excellentes... Si on aime la musique éléctronique d'ambiance bien-sûr.

Pour les programmeurs je ne peux que conseiller cette musique elle permet une bonne concentration sans fatigue auditive.

http://www.kahvi.org/

Des compilations se trouve ici:
http://www.kahvi.org/m01.php

Tuesday, October 9, 2007

3 ans...


... qu'Adrian a réussi à passer sans blessures dignes de ce nom.
(ou plutôt qu'on a été assez rapide pour l'empêcher de se tuer).

Mais aujourd'hui il expérimente: brulure sur une poêle et coupure avec une collection de petits débris, terre, etc.

Il pleure comme une madeleine s'il ne reçoit pas un chocolat mais il est resté stoïque pendant que je lui nettoyais la coupure avec une loupe et une pince Brussel (ou à écharde).

Brave garçon il a mérité son chocolat :)