Subj : Re: Multi-Thread and memory allocation error (or bug in 5.02). To : borland.public.cpp.borlandcpp From : "Martin Catney" Date : Mon Sep 01 2003 07:32 pm Hi Bob, Changing the thread creation to after the memory allocation did not help. The application still crashes. j equals 2 to answer your other point. Changing the order of deleting the array fixed the problem in the example but did not help in the real code which is more complex and has other objects being created which can not be deleted in reverse order. I will of course check that the problem in the real code does not stem from another unrelated problem. Thanks Martin "Bob Gonder" wrote in message news:768vkv4cujkef85n31h2bp19dh4o251on4@4ax.com... > Martin Catney wrote: > > > >I get an access violation at 0x634b5e: read of address 0x4cdc058 when I run > >the example. This corresponds to the line > >delete[] array; > > It might be instructive to know the value of j at that point. > > >Does anyone spot an obvious error in my example or is this a bug in the > > Just some thoughts... > I would think you should create the arrays before you start the > thread. > > And I would change this > > > for (int j=0; j < mLength ; j++){ > > array = thearray[j]; > > delete[] array; > > } > to this > while( mLength-- ) //mLength no longer needed > delete[] theArray[ mLength ]; // reverse order of new > > I would also make "array" a local variable instead of an object > member. At least, the code you gave doesn't require a member named > "array". > > Don't know if any of that will fix your problem, but I'd start there. > > > .