Assert fails when destructing combination of GAlib objects
Wendy van Olmen
Wendy.vanOlmen at uia.ac.be
Sun Sep 8 04:00:41 EDT 2002
Olaf,
I didn't find time to study the problem in depth. I 'solved' it by only
calling the algorithm with GA1DArrayGenome<PartialGenome>'s of size
2...
Sorry I couldn't be of more help.
Wendy
----- Original Message -----
From: "Olaf Meding" <olaf at tomotherapy.com>
To: <galib at mit.edu>
Sent: Tuesday, September 03, 2002 10:52 PM
Subject: Assert fails when destructing combination of GAlib objects
> Wendy,
>
> 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.
>
>
> Olaf
>
>
>
> (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
> type
>
> 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:
>
> _CrtIsValidHeapPointer(pUserData)
>
> 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. */
>
> _ASSERTE(_CrtIsValidHeapPointer(pUserData));
>
> (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
> trace:
>
> (~ procedure call stack)
>
> _free_dbg_lk(void*, int)
> _free_dbg(void*, int)
> free(void*)
> operator delete(void*)
> GAArray<int>::~GAArray<int> ()
> GA1DArrayGenome<int>::~GA1DArrayGenome<int> ()
> GA1DArrayAlleleGenome<int>::~GA1DArrayAlleleGenome<int>
> (*) PartialGenome::~PartialGenome()
> GAArray<PartialGenome>::~GAArray<PartialGenome>()
> GA1DArrayGenome<PartialGenome>::~GA1DArr...
> GAPopulation::~GAPopulation()
> GASimpleGA::~GASimpleGA().
>
> 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
>
> _______________________________________________
> galib mailing list
> galib at mit.edu
> http://lancet.mit.edu/mailman/listinfo/galib
More information about the galib
mailing list