Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Probably a memory leak when forcing opengl on windows

This thread is locked; no one can reply to it. rss feed Print
Probably a memory leak when forcing opengl on windows
Aikei_c
Member #14,871
January 2013
avatar

I used the same tutorial I use every time to check for allegro bugs:
http://wiki.allegro.cc/index.php?title=Basic_tutorial_on_loading_and_showing_images
But I added the line:

al_set_new_display_flags(ALLEGRO_OPENGL);

right before creating the display. I checked with Memory Validator (http://www.softwareverify.com/cpp-memory.php) for leaks after program termination and I get 4 leaks at the end of the program, all of which have something to do with the following calls (I'll put the * marks around the line which memory validator complains about:

1. system.c

    236  :    /* Check for a user-defined system driver first */
    237  :    real_system = find_system(&_user_system_interfaces);
    238  : 
    239  :    /* If a user-defined driver is not found, look for a builtin one */
    240  :    if (real_system == NULL) {
    241  :       *real_system = find_system(&_al_system_interfaces);*
    242  :    }
    243  : 
    244  :    if (real_system == NULL) {
    245  :       active_sysdrv = NULL;
    246  :       return false;

|
V
2. system.c

    56   :    unsigned int i;
    57   : 
    58   :    for (i = 0; i < vector->_size; i++) {
    59   :       sptr = _al_vector_ref(vector, i);
    60   :       sys_interface = *sptr;
    61   :       *if ((system = sys_interface->initialize(0)) != NULL)*
    62   :          return system;
    63   :    }
    64   : 
    65   :    return NULL;
    66   : }

|
V
3. wsystem.c

    167  : 
    168  :    _al_vector_init(&_al_win_system->system.displays, sizeof (ALLEGRO_SYSTEM_WIN *));
    169  : 
    170  :    _al_win_system->system.vt = vt;
    171  : 
    172  :    *d3d_available = maybe_d3d_init_display();*
    173  : 
    174  :    return &_al_win_system->system;
    175  : }
    176  : 
    177  :

|
V
4. wsystem.c

    141  : 
    142  : 
    143  : static bool maybe_d3d_init_display(void)
    144  : {
    145  : #ifdef ALLEGRO_CFG_D3D
    146  :    *return _al_d3d_init_display();*
    147  : #else
    148  :    return false;
    149  : #endif
    150  : }
    151  :

|
V
5. d3ddisp.cpp

    694  : 
    695  : 
    696  :    ALLEGRO_INFO("Render-to-texture: %d\n", render_to_texture_supported);
    697  : 
    698  :    present_mutex = al_create_mutex();
    699  :    *_al_d3d_lost_device_mutex = al_create_mutex();*
    700  : 
    701  :    _al_d3d_bmp_init();
    702  : 
    703  :    return true;
    704  : }

|
V
6. threads.c

    281  : ALLEGRO_MUTEX *al_create_mutex(void)
    282  : {
    283  :    ALLEGRO_MUTEX *mutex = al_malloc(sizeof(*mutex));
    284  :    if (mutex) {
    285  :       _AL_MARK_MUTEX_UNINITED(mutex->mutex);
    286  :       *_al_mutex_init(&mutex->mutex);*
    287  :    }
    288  :    return mutex;
    289  : }
    290  : 
    291  :

|
V
7. wxthread.c

    97   : void _al_mutex_init(_AL_MUTEX *mutex)
    98   : {
    99   :    ASSERT(mutex);
    100  : 
    101  :    if (!mutex->cs)
    102  :       *mutex->cs = al_malloc(sizeof *mutex->cs);*
    103  :    ASSERT(mutex->cs);
    104  :    if (mutex->cs)
    105  :       InitializeCriticalSection(mutex->cs);
    106  :    else
    107  :       abort();

|
V
8. memory.c

    39   :    int line, const char *file, const char *func)
    40   : {
    41   :    if (mem)
    42   :       return mem->mi_malloc(n, line, file, func);
    43   :    else
    44   :       *return malloc(n);*
    45   : }
    46   : 
    47   : 
    48   : 
    49   : /* Function: al_free_with_context

Then there are three more, which also have something to do with creating mutexes in _al_d3d_init_display();

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

fyi, the code tag comes with a bonus - if you put 3 asterisks after a line of code it will highlight that line of code for you, usually unless it chokes, but it does fine most the time.

Too bad it can't find the offending line of code that frees the mem that doesn't exist yet. Now then it would be a good memory tool.

Fix the leak! Submit a patch against git!

Aikei_c
Member #14,871
January 2013
avatar

Unfortunately, I'm too noob of a programmer to do that myself.

pkrcel
Member #14,001
February 2012

Why forcing an OpenGL Display should let Allegro Stakc the calls into the D3D submodule? ???

It is unlikely that Google shares your distaste for capitalism. - Derezo
If one had the eternity of time, one would do things later. - Johan Halmén

Go to: