Assert fails when destructing combination of GAlib objects

Olaf Meding olaf at
Tue Sep 3 16:52:37 EDT 2002


Did you ever find out what the problem you described below was?  I am having
the same problem and found you message on the Internet.

Thanks much in advance for your time and help.


(I know it's a long mail, but if you think you know what you are doing,
please don't let this scare you! I just tried to make everything as
clear as possible and I could really do with the help.)

I am a final year student and currently I am working on my thesis. Using
genetic algorithms I try to optimize the load and balance of air cargo.

The datastructure I am using to represent possible solutions is based on
a combination of classes provided by GAlib.
It all boils down to:

     GA1DArrayGenome< GA1DArrayAlleleGenome<int> >

When I tried to use it like this (in Microsoft Visual Studio) there
where some problems. I suspect because of the 'template in the
template', but I don't remember exactly.

That's why I made some wrapper class PartialGenome and I use genomes of

     GA1DArrayGenome< PartialGenome >

PartialGenome just contains one member of type
GA1DArrayAlleleGenome<int>. The constructors and destructors I supplied
only (implicitely) pass on the work to the GAlib constructors and
destructors of the member. So I really don't see anything that could go
wrong here.

Everything works fine when I use GA1DArrayGenome<PartialGenome> of size
2, but when I need three or more PartialGenomes something goes wrong at
the destruction fase.

I get the following message:

     Debug Assertion Failed:


This refers to a line in \VC98\CRT\SRC\DBGHEAP.C:

     /* If this ASSERT fails, a bad pointer has been passed
     /* in.  It may be totally bogus, or it may have been
     /* allocated from another heap.  The pointer MUST come
     /* from the 'local' heap.  */


(So it has nothing to do with the void* userData of GAlib!)

I am calling my optimization function (in which I use GAlib) from a Java
application through the Java Native Interface. This works fine. The
down-side is that I can't properly debug. The only help I get is this

(~ procedure call stack)

     _free_dbg_lk(void*, int)
     _free_dbg(void*, int)
     operator delete(void*)
     GAArray<int>::~GAArray<int> ()
     GA1DArrayGenome<int>::~GA1DArrayGenome<int> ()
(*)  PartialGenome::~PartialGenome()

It always goes wrong at the destruction of the third PartialGenome at
line (*).

To be able to get on with my testing I commented out the line

     delete [] a;

in virtual ~GAArray() in GAArray.h .  I know this results in a major
memory leak, but desperate situations call for desperate measures.

This is where you come in to play:
if you have any idea on what goes wrong, where it goes wrong, why it
goes wrong or what I can do about it,  please let me know,  because
valuable time is ticking away!

If you've made it this far I would like to thank you for the effort. I
hope to hear from you soon.

Kind regards,

Wendy van Olmen
Mathematics - Computer Science
University Of Antwerp

More information about the galib mailing list