?
Solved

Free tables from memory

Posted on 2003-04-01
11
Medium Priority
?
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

801 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