Out of Memory

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Monkey
Newbie
Newbie
Posts: 12
Joined: Wed Nov 09, 2005 5:00 am

Out of Memory

Post by Monkey » Mon Oct 06, 2008 9:21 am

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.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Oct 06, 2008 10:14 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Monkey
Newbie
Newbie
Posts: 12
Joined: Wed Nov 09, 2005 5:00 am

Post by Monkey » Fri Oct 10, 2008 1:16 pm

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.
Last edited by Monkey on Tue Oct 14, 2008 2:45 pm, edited 2 times in total.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Oct 10, 2008 2:48 pm

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;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Monkey
Newbie
Newbie
Posts: 12
Joined: Wed Nov 09, 2005 5:00 am

Post by Monkey » Mon Oct 13, 2008 9:19 am

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.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Oct 13, 2008 12:06 pm

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;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Monkey
Newbie
Newbie
Posts: 12
Joined: Wed Nov 09, 2005 5:00 am

Post by Monkey » Mon Oct 13, 2008 12:26 pm

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.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Oct 13, 2008 1:09 pm

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply