App kept crashing with access violation!!!!
App kept crashing with access violation!!!!
Hi,
The chart kept popping up dialog box saying access violation in some address. This problem happens in some PCs, but not in all. Is it related with how I distribute the ActiveX control?
I used AddXY to add some data for a scLine series, then the error occurs.
Thanks a lot.
David
The chart kept popping up dialog box saying access violation in some address. This problem happens in some PCs, but not in all. Is it related with how I distribute the ActiveX control?
I used AddXY to add some data for a scLine series, then the error occurs.
Thanks a lot.
David
Last edited by David on Mon Dec 04, 2006 7:15 am, edited 1 time in total.
-
- Newbie
- Posts: 15
- Joined: Mon Jun 26, 2006 12:00 am
- Location: San Diego, Ca.
ActiveX Memory Error
Had the same problem, mainly with large ( greater than 20,000 data points). Two parts, first is you need to use AddArray plus make the allocation larger than you need for the ole-safe-array. Second, so that the chart-ocx can handle the large array, fill the array with random data when you initialize, so when you give it the real data-array the chart has already sized itself internally. I also wrote some exception handlers to when using large data sets. Hope this helps.
Hi, John,
Thanks for your info. Would you please tell me how to allocate larger array for the AddArray? When you fill the array with random data, will it appear in the display? Also, I am not familiar with the exception handling. It would be greatly appreciated if you could give me some brief knowledge.
Thanks a lot.
David
Thanks for your info. Would you please tell me how to allocate larger array for the AddArray? When you fill the array with random data, will it appear in the display? Also, I am not familiar with the exception handling. It would be greatly appreciated if you could give me some brief knowledge.
Thanks a lot.
David
Hello David,
We have run extensive tests with the sample project you sent and unfortunately haven't yet been able to find the cause of the error, or even exactly how it is occurring. John's suggestion to use AddArray with memory allocation is worthwhile trying as in initial tests here, when that technique is included, are positive (ie. we haven't been able to provoke the error). Thanks for the input John.
ie (syntax similar to TeeChart's VC++AddArray demo)
Regards,
Marc
We have run extensive tests with the sample project you sent and unfortunately haven't yet been able to find the cause of the error, or even exactly how it is occurring. John's suggestion to use AddArray with memory allocation is worthwhile trying as in initial tests here, when that technique is included, are positive (ie. we haven't been able to provoke the error). Thanks for the input John.
ie (syntax similar to TeeChart's VC++AddArray demo)
Code: Select all
void CFHTesterDlg::AssignData1(double &dInitIndex)
{
int nDataNum = 5000;
double dSum = 0.0;
int nFirst = 0;
double dX = 0.0;
COleSafeArray XValues;
COleSafeArray YValues;
DWORD numElements[] = {200000};
// Create the safe-arrays...
XValues.Create(VT_R8, 1, numElements);
YValues.Create(VT_R8, 1, numElements);
for(long i = 0;i<nDataNum;i++)
{
dSum = rand();
dX = dInitIndex + i + 1;
XValues.PutElement(&i, &dX);
YValues.PutElement(&i, &dSum);
}
// Add arrays
m_chart1.Series(0).AddArray( nDataNum,YValues,XValues);
dInitIndex = m_chart1.Series(0).GetXValues().GetMaximum();
}
Marc
Last edited by Marc on Tue Dec 05, 2006 12:59 pm, edited 1 time in total.
Steema Support
-
- Newbie
- Posts: 15
- Joined: Mon Jun 26, 2006 12:00 am
- Location: San Diego, Ca.
Increasing the Size of a safe Array & Exception Handling
// Code Snipit for increasing
COleSafeArray XValues;
COleSafeArray YValues;
long MaxPlotPoints;[/code]
...
// Initial Creating, somewhere in init_foo()
XValues.Create(VT_R8, 1, &MaxPlotPoints );
YValues.Create(VT_R8, 1, &MaxPlotPoints );
...
// Resize function
BOOL CMojoClass::CheckSafeArraySize(void)
{
BOOL resize = FALSE;
long tmpSize = MaxPlotPoints;
long CellCntEst = (long)CellArrayClnt.Count(); // get the size
if( MaxPlotPoints < CellCntEst )
{
if( CellCntEst > 25000 )
MaxPlotPoints = 50000;
if( CellCntEst > 50000 )
MaxPlotPoints = 75000;
if( CellCntEst > 75000 )
MaxPlotPoints = 100000;
if( CellCntEst > 100000 )
MaxPlotPoints = 150000;
if( CellCntEst > 150000 )
MaxPlotPoints = 200000;
if( CellCntEst > 200000 )
MaxPlotPoints = 250000;
if( CellCntEst > 250000 )
MaxPlotPoints = 500000;
if( CellCntEst > 500000 )
MaxPlotPoints = 750000;
if( CellCntEst > 750000 )
MaxPlotPoints = 1000000;
resize = TRUE;
}
if( TRUE == resize )
{
SAFEARRAYBOUND sbArray[1];
//long uBound; // upper-bound, last index value
//long lBound; // lower-bound, usually zero
sbArray[0].cElements = MaxPlotPoints+1;// uBound;
sbArray[0].lLbound = 0;// lBound;
XValues.Redim( sbArray );
YValues.Redim( sbArray );
#ifdef _DEBUG
TRACE("Resized SafeArrays; from:%lu to: %lu \n", tmpSize, MaxPlotPoints );
#endif
}
return resize;
}
//.. exception handling when the ocx takes a shit
//| Try and handle the coloring, sometimes to fast for the Ole-Interface
TRY
{
//| Color the Data-Point
m_pChart->Series(ActiveSeriesIdx).SetPointColor(idx, PointColor);
}
CATCH( COleDispatchException, e )
{
// AfxMessageBox ("ColorEvents: Ole Exception Called!", NULL, MB_OK );
ReColorEvents = TRUE;
break;
}
END_CATCH
//.. I pass the ReColorEvents flag up on level and then try again,
//.. usually the TeeChart ocx has ajusted its memory by then and I
//.. can continue to color the plotted points.
//.. I'm not able to reproduct this in a non-dialog based app. So I'm trimming down my app to send to steema as an example of both heap errors and exceptions thrown by the ocx. Hopefully by the end of the day.
COleSafeArray XValues;
COleSafeArray YValues;
long MaxPlotPoints;[/code]
...
// Initial Creating, somewhere in init_foo()
XValues.Create(VT_R8, 1, &MaxPlotPoints );
YValues.Create(VT_R8, 1, &MaxPlotPoints );
...
// Resize function
BOOL CMojoClass::CheckSafeArraySize(void)
{
BOOL resize = FALSE;
long tmpSize = MaxPlotPoints;
long CellCntEst = (long)CellArrayClnt.Count(); // get the size
if( MaxPlotPoints < CellCntEst )
{
if( CellCntEst > 25000 )
MaxPlotPoints = 50000;
if( CellCntEst > 50000 )
MaxPlotPoints = 75000;
if( CellCntEst > 75000 )
MaxPlotPoints = 100000;
if( CellCntEst > 100000 )
MaxPlotPoints = 150000;
if( CellCntEst > 150000 )
MaxPlotPoints = 200000;
if( CellCntEst > 200000 )
MaxPlotPoints = 250000;
if( CellCntEst > 250000 )
MaxPlotPoints = 500000;
if( CellCntEst > 500000 )
MaxPlotPoints = 750000;
if( CellCntEst > 750000 )
MaxPlotPoints = 1000000;
resize = TRUE;
}
if( TRUE == resize )
{
SAFEARRAYBOUND sbArray[1];
//long uBound; // upper-bound, last index value
//long lBound; // lower-bound, usually zero
sbArray[0].cElements = MaxPlotPoints+1;// uBound;
sbArray[0].lLbound = 0;// lBound;
XValues.Redim( sbArray );
YValues.Redim( sbArray );
#ifdef _DEBUG
TRACE("Resized SafeArrays; from:%lu to: %lu \n", tmpSize, MaxPlotPoints );
#endif
}
return resize;
}
//.. exception handling when the ocx takes a shit
//| Try and handle the coloring, sometimes to fast for the Ole-Interface
TRY
{
//| Color the Data-Point
m_pChart->Series(ActiveSeriesIdx).SetPointColor(idx, PointColor);
}
CATCH( COleDispatchException, e )
{
// AfxMessageBox ("ColorEvents: Ole Exception Called!", NULL, MB_OK );
ReColorEvents = TRUE;
break;
}
END_CATCH
//.. I pass the ReColorEvents flag up on level and then try again,
//.. usually the TeeChart ocx has ajusted its memory by then and I
//.. can continue to color the plotted points.
//.. I'm not able to reproduct this in a non-dialog based app. So I'm trimming down my app to send to steema as an example of both heap errors and exceptions thrown by the ocx. Hopefully by the end of the day.
Hi, John,
Thank you so much! I will look through the code and hopefully it will solve my problem. I just have one question. In my app, when the access violation occurs, the ocx stops updating, which means no new data can be plotted. With this exception handling, will it be able to update again?
Thanks a lot!
David
Thank you so much! I will look through the code and hopefully it will solve my problem. I just have one question. In my app, when the access violation occurs, the ocx stops updating, which means no new data can be plotted. With this exception handling, will it be able to update again?
Thanks a lot!
David
-
- Newbie
- Posts: 15
- Joined: Mon Jun 26, 2006 12:00 am
- Location: San Diego, Ca.
Update after Exception
Yes, things should be ok ...
But If the OleSafeArray is the problem, maybe not. I've not really found any really good info on OleSafeArray, but where it is created and updated, ie scope and thread, is very important. I usually keep it within the process and I do not pass it around.
But If the OleSafeArray is the problem, maybe not. I've not really found any really good info on OleSafeArray, but where it is created and updated, ie scope and thread, is very important. I usually keep it within the process and I do not pass it around.
Hi,
It seems the problem remains unkilled here. So is there any good news with the bug hunting? Is it possible that you could fix it by the end of this year? If not, I would have to remove it from my app and try some other way to display data, which is the last thing I would like to do. So although it is Christmas time, do please help me solve it sooner and keep me updated.
Merry X'mas to all!
David
It seems the problem remains unkilled here. So is there any good news with the bug hunting? Is it possible that you could fix it by the end of this year? If not, I would have to remove it from my app and try some other way to display data, which is the last thing I would like to do. So although it is Christmas time, do please help me solve it sooner and keep me updated.
Merry X'mas to all!
David
Hello David,
We still don't have a definitive cause identified for this issue. It's related to threads and paint process. It may be that the thread created on the existing Chart interferes with the standard repaint cycle of that Chart. If the creation of the entire Chart were to lie within the thread cycle the issue may not occur. To try to negate that behaviour we can set AutoRepaint to false and repaint the Chart only on demand.
Eg.
and...
Another clue to the paintcycle/thread hypothesis is that the Chart in tests was reacting badly to a mouseover whilst the data is being loaded. With AutoRepaint false it has been behaving correctly. That would need to be applied to all Charts being data-loaded in this way.
I hope that may be of help.
Regards,
Marc
We still don't have a definitive cause identified for this issue. It's related to threads and paint process. It may be that the thread created on the existing Chart interferes with the standard repaint cycle of that Chart. If the creation of the entire Chart were to lie within the thread cycle the issue may not occur. To try to negate that behaviour we can set AutoRepaint to false and repaint the Chart only on demand.
Eg.
Code: Select all
void CFHTesterDlg::Chart1Init()
{
m_chart1.SetAutoRepaint(false);
//....other initialisation routines...
}
Code: Select all
void CFHTesterDlg::AssignData1(double &dInitIndex)
{
//....add data routine....
// then:
m_chart1.SetAutoRepaint(true);
m_chart1.Repaint();
m_chart1.SetAutoRepaint(false);
}
I hope that may be of help.
Regards,
Marc
Steema Support
Hi, Marc,
I tried your method and it does help, but unfortunately, it didn't solve it. I removed the finite time repaint in the thread so that the repaint would continue until I click the stop button. It seemed with your method, the app can run correctly most of the time, but the erro would still occur sometimes. I also tried adding some delay before assign data, still the same problem.
With this kind of problem, we can't deliver to our customer. I do appreciate the help from you and other teechart staffs, but I have to consider some other way to display the data. I just hope you could solve this problem as soon as possible so that I will still be able to use it in my future projects. Please keep me updated.
Thanks a lot and merry Christmas!
David
I tried your method and it does help, but unfortunately, it didn't solve it. I removed the finite time repaint in the thread so that the repaint would continue until I click the stop button. It seemed with your method, the app can run correctly most of the time, but the erro would still occur sometimes. I also tried adding some delay before assign data, still the same problem.
With this kind of problem, we can't deliver to our customer. I do appreciate the help from you and other teechart staffs, but I have to consider some other way to display the data. I just hope you could solve this problem as soon as possible so that I will still be able to use it in my future projects. Please keep me updated.
Thanks a lot and merry Christmas!
David