Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

memory penalty for multiple workareas?

Status
Not open for further replies.

yert33

Programmer
Feb 19, 2002
255
US
Is there a memory penalty for having a lot of workareas open at once?

I'm thinking i could just open all 300 files at the beginning and forget about it.....

Whaddya think?
 

The overhead for 300 work areas would be negligible. But the overhead for 300 open tables would be substantial (remember, each table can be up to three physical files -- so 900 files).

But, regardless of the question of overhead, you've also got to think about how you'd manage such a large number of open tables. Presumably, with so many tables, this is a pretty big application. If you open all the tables at startup, they will all be open in the same data session. That will have big implications for how you keep track of aliases, making sure all the buffers are cleared, dealing with transactions, and all the other details.

I'm not saying you shouldn't do it -- but I do question that it's the best approach.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
In addition to Mike's comments, opening 300 tables at one time would not make your users very happy as they sit there waiting for the app to start. It's a lot more user friendly to just open what you need when you need it.

Just my 2 cents,
Jim
 
That will have big implications for how you keep track of aliases, making sure all the buffers are cleared, dealing with transactions, and all the other details.
It can also increase the risk of data corruption. Data might be lost on any table that's open when the power (or the network or the PC or the user) suffers a failure.

Geoff Franklin
 
I agree with the prior post. The more tables open, the greater the risk of some electrical glitch or computer/network/server failure corrupting multiple files. The key is maintaining a reasonable and fair balance, not fewer open than you need, not more open than you need.

In the old days computer issues were speed and capacity, so that was the main consideration when opening only a few tables at a time. But be aware that even with fast computers, one of the slowest operations is still opening files.
 

Another issue to consider is the use of data sessions.

If you open all the tables up front, this implies that the entire application will share a single data session. That might be the right approach in some cases, but it's often preferable to give each form its own data session. This means that each form will be responsible for opening and closing its own tables.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Actually, Mike, opening the tables in the default data session does give you faster performance in private data sessions. The slow part is opening the file; once it's open, you can open it again faster.

Tamar
 

Tamar,

opening the tables in the default data session does give you faster performance in private data sessions.

Thanks for reminding me of that. The point I was trying to make was more to do with encapsulation than performance. Maybe encapsulation's the wrong word. I was thinking of letting forms have private data sessions in order to keep them self-contained.

What you're saying is that you can open all the tables up front, and still open them again in private data sessions. Worth remembering.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks for all the replies - learned a lot. What impact on RAM does opening a table have? Just a few bytes for the file handle?

 
Yes, that is true. Just a Curious George moment of mine.
 
A few years ago I wrote an application for myself which opened all the tables (only 30).


Lets just say it wasn't one of my better attempts, I wouldn't do it again.


Richard Clark

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top