Is tying over 5 hashes on a single page considered a waste of memory? If I try to tye..20 databases at a time would that, generally speaking, have a big increase on load time?
What is a "page"? Perl doesn't have any concept of "pages", so your question is a bit strange. If you mean whether tying 5 hashes in a single program is considered a waste of memory, it all depends what your program does. If your program calculates the first 100 prime numbers, even tying a single hash is probably a waste. If your program does a tax audit for all people in the US, it might not be a waste.
As for "tying to 20 databases" (do you mean connecting?) it will certainly take some time. But whether that's a big increase depends on the rest of the program, doesn't? Consider your databases are heavily loaded, and on average it takes a second to connect to a single database. That 20 seconds. If your program runs for a week, the 20 seconds don't matter. If your program is run every 10 seconds, the 20 seconds do matter.
The problem with your questions is that they can't be answered without knowing a lot more about the specific program.
Would it use a lot of memory if I used an automated script to parse the text of a url every 5 minutes?
That depends on what you find a lot, how much text there is to parse, how you parse it, and what you are doing with the results. The best way to get an answer is to write the program and test it.
Is it faster to do a foreach ( keys %hash) { $cnt++ or storing the hash into an array to count key/value pairs?
That's probably the wrong question to ask. It all depends on what your purpose is of storing the data. If all you care about is "how many", both a hash and an array are silly. If you want to do something else, than that something else decides whether a hash or an array is the most useful. Both scalar keys %hash and scalar @array are constant time operations.
What are some common areas or traps that would increase memory wastage?
The first is: using Perl itself. Once you have committed yourself to use Perl, you are going to use a lot of memory. If you are in a situation where the memory usage of as few as 5 tied hashes are a valid concern, you shouldn't have used Perl in the first place.
Use C. That seems to be ideal for you - there you have lots of control over the memory usage.
Abigail
In reply to Re: Memory /speed questions
by Abigail-II
in thread Memory /speed questions
by sulfericacid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |