Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Free tables from memory

Posted on 2003-04-01
11
Medium Priority
?
217 Views
Last Modified: 2010-04-06
I have an application that load a table when I create a second from.
Initial my app have ~6MB. When I create the second form ( and open the table ) my used memory grow to ~10 MB.
When close (destroy) the Form2 the used memory is ~8MB.

I try same job without open the table. When create Form2 the memory is ~7MB and when close (destroy) it is back 6MB. PERFECT. This mean that the lost 2MB are used my table.

What to do to can clear the used memory by table?
I have try with Table.Free, Table.Close, Table.Active:=False, Table.Destroy ...no result :(


WHAT TO DO ????
0
Comment
Question by:ginsonic
  • 5
  • 5
11 Comments
 
LVL 1

Expert Comment

by:grolschisgood
ID: 8245216
im just posting this message so i can get emails on further comments posted cause this interests me.  Could this have something to do with caching?

Maybe more info needed on type on connections and databsae server..
0
 
LVL 4

Expert Comment

by:Colin_Dawson
ID: 8249027
I need some more information on this Table object of yours. Are you talking about a TTable? or A TadoTable or something else entirely?
0
 
LVL 9

Author Comment

by:ginsonic
ID: 8251123
Is a fox dbf table (TTable).
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Accepted Solution

by:
Colin_Dawson earned 1000 total points
ID: 8256063
Ah ha.  This is a known problem with the TTable component, Delphi will cache the table in memory.

My Personal view on this is stop using the TTable component, Use the TQuery instead, whilst it does make things a little more complex, it allows you greater control over the data.
0
 
LVL 9

Author Comment

by:ginsonic
ID: 8259046
I don't use untill now the TQuery compo. Can I just replace the TTable and use same tables with no more code? Can I use index, filter, pack the tables asa TTable?

Can you give me more details ?
0
 
LVL 4

Expert Comment

by:Colin_Dawson
ID: 8263384
You can't simply swap the components.

A TQuery is a component that allows you to make SQL calls to the database.   An SQL statement could look like this:

Select ID, DESCRIPTION from MYTABLE

This will select only the ID and DESCRIPTION fields from the database.

There are also commands INSERT, UPDATE and DELETE that allow you to modify the data.

Since you've not used the TQuery before I don't think it'll be a good idea to change all your code over for this.


What happens if you open, close then reopen your TTable?  If you don't use any extra memory, then I don't really think it's worth worrying about.
0
 
LVL 9

Author Comment

by:ginsonic
ID: 8267151
My project is just at start. I will use a lots of tables. If I spend 2MB from memory just for a table what will happening when I will use 20-30 ?
0
 
LVL 4

Expert Comment

by:Colin_Dawson
ID: 8270899
In that case, design your prject to work entirely from TQueries.   You will be able to do everything that you want to... and more.  It's worth spending some time hitting the books though as moving from TTable to TQuery is a complete change in philosophy.
0
 
LVL 9

Author Comment

by:ginsonic
ID: 8271086
This involve suplimentar licenses ? SQL or something else ?
0
 
LVL 4

Expert Comment

by:Colin_Dawson
ID: 8274459
Using a TQuery doesn't need any suplimental Licence. You will need to use a SQL though.

Since you're using the BDE for access and DBF files for storage, all the SQL that you need is already build into your machine.

Here's some advantages to using a TQuery....

1. Return custom datasets by combining information from several tables together.


Example SQL....
  select a.ID, a.Description, b.PostCode
  From Customers a,
       Address b
  where a.AddressID = b.AddressID

2. Create Datasets that do not cache anything in memory -i.e. forward only.   The TQuery.Next will work but not the TQuery.First, or TQuery.Prior.

It's handy for loading lookup lists into Combo boxes and stuff like that. (it's also faster)

3. With careful planning you can easily implement non-dbaware controls as though they are dbaware.   Final apps tend to look better.
0
 
LVL 9

Author Comment

by:ginsonic
ID: 8274772
It's time to learn SQL :)

Thanks!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question