ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  C++ how to check if a chart's memory was released?
Posted by Rachel on Jul-16-2018 11:46
Hi,

I started to work on chart director with C++.
and I am getting a lot of crashes.
I am trying to find a way to check if memory were released with no success.
what is the way to do that?
for instance,
I am saving a Layer of Chart, but the Chart's Memory were released, and that also released the memory of it's Layer.
How can I check if the (Layer == nullptr)

Thanks,
Rachel.

  Re: C++ how to check if a chart's memory was released?
Posted by Peter Kwan on Jul-16-2018 22:41
Hi Rachel,

In C++, it is not possible to check if any memory is released. The programmer would need to keep track of the memory.

Checking if a pointer is equal to nullptr has no effect. For example:

int *xxx = new int[100];
xxx = 0;
int *yyy = new int[100];
delete[] yyy;

In the above code, xxx is equal to nullptr, but the memory is not released. On the other hand (yyy != nullptr), but memory is released. So whether a pointer is nullptr or not has no relationship to whether the memory is released or not.

In ChartDirector, if an object is a part of the chart (such as a Layer is part of an XYChart), then if the XYChart is released, the Layer is also released. All points you obtain from the chart (eg. using addLineLayer, or using makeChart, etc) are part of the chart and will be released when the chart is released. So for your case, you just need to keep track of whether the chart that creates the Layer is released or not.

Regards
Peter Kwan