Page 1 of 1

Out of Memory

Posted: Mon Oct 06, 2008 9:21 am
by 9239148
Hi,

What is the best way to free up memory that has been allocated to the data stored in a TIsoSurfaceSeries? I tried using the .Clear method but I still seem to get an "Out of Memory" error.

Thanks,
Monkey.

Posted: Mon Oct 06, 2008 10:14 am
by narcis
Hi Monkey,

Clear method disposes all series ValueLists so I think this should be enough. You could also try freeing series:

Code: Select all

  Series1.Free;
If the problem persists please send us a simple example project we can run "as-is" to reproduce the problem here.

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.

Posted: Fri Oct 10, 2008 1:16 pm
by 9239148
Hi Narcís,

The .free method causes me an access violation error when it is called:

Image

An attempt to read address zero seems strange.

I appreciate that it would help to solve the issue, but I'm afraid that I am unable to send a working version of the project. I did reproduce the series.free problem within a seperate test project (Testing.zip), which I have uploaded to your server.

Best Regards,
Monkey.

Posted: Fri Oct 10, 2008 2:48 pm
by narcis
Hi Monkey,

Thanks for the example project.

It works fine for me here using TeeChart Pro v8.04 VCL (which we just posted at the client area) and commenting in the Free call as shown below. Why are you trying to free the series in a loop where you are populating it? It doesn't make much sense for me.

Code: Select all

    for x:=-m to m do
    begin
      tmpX:=sqr(x/30);
      for z:=-m to m do
      begin
        tmpZ:=Sqr(z/30);
        tmpZ:=Sqrt(tmpX + tmpZ);

        m_SurfaceSeries.AddXYZ(x,2*(4*cos(3*tmpZ)*exp(-0.5*tmpZ)), z);
        //m_SurfaceSeries.free;
     end;
   end;
It also works fine for me freeing series after it has been populated, for example:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  m_SurfaceSeries.Free;
end;

Posted: Mon Oct 13, 2008 9:19 am
by 9239148
Hi Narcís,
narcis wrote:Why are you trying to free the series in a loop where you are populating it? It doesn't make much sense for me.
My project contains a procedure similar to the one in the example project that uses a loop to populate the series. I wanted to simulate what is happening in that project. If I put the Free call within the loop, I get an access violation error like the one in my previous post. If I put the Free call after the loop, it works fine (and I get no data displayed, as expected).

Since I may need to free the series part way through populating it (for example, due to a flag condition being set), I would like to be able to put the call within the loop.

I am using TeeChart Pro v7.04.

Again, a memory access violation error seems strange. If you uncomment the free call, do you experience the same issue?

Also, i am still in the middle of investigating to see if the Free method solves my orginal Out of Memory issue.

Best Regards,
Monkey.

Posted: Mon Oct 13, 2008 12:06 pm
by narcis
Hi Monkey,

Ok, in that case you can exit the loop after freeing the series:

Code: Select all

    for x:=-m to m do
    begin
      tmpX:=sqr(x/30);
      for z:=-m to m do
      begin
        tmpZ:=Sqr(z/30);
        tmpZ:=Sqrt(tmpX + tmpZ);
        m_SurfaceSeries.AddXYZ(x,2*(4*cos(3*tmpZ)*exp(-0.5*tmpZ)), z);
        m_SurfaceSeries.free;
        exit;
     end;

Posted: Mon Oct 13, 2008 12:26 pm
by 9239148
Hi Narcís,

Thanks for the tip :)

So is this error caused by attempting to call the Free method on an empty series? If this is the case, is there any way to check to see if the series contains any data before attempting to Free it?

Also, if you uncomment the free call, do you experience the same issue?

Best Regards,
Monkey.

Posted: Mon Oct 13, 2008 1:09 pm
by narcis
Hi Monkey,

No, the problem is try to access a series which has already been freed. If you add a breakpoint add the series AddXYZ call you'll see it crashes at the second time the execution arrives there since series was freed in the previous loop.

You can check if series has data checking its Count property, if Count>0 then it has data.

Yes, I also experience the same problem using Free as you did.