473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

memory allocated for arrays in perl

dear friends
thanks for the mail sent
today i have one more question:
1. since in perl arrays need not be declared, [i.e arrays are expandable], what is the maximum limit of elements an array could have?
2. in java/ c/ c++, if we declare an array with 5 elements it can have utmost 5 elements, and we could also know what is the memory allocated for an array. how do we know it in perl
3. how many bytes does a scalar , array, list and hashes occupy.
though most of the questions are elementary, but iam unable to get answers for these from the other books and hence i request the board members to clarify it
with regards
rathankar
Oct 7 '07 #1
2 4238
numberwhun
3,509 Expert Mod 2GB
dear friends
thanks for the mail sent
today i have one more question:
1. since in perl arrays need not be declared, [i.e arrays are expandable], what is the maximum limit of elements an array could have?
2. in java/ c/ c++, if we declare an array with 5 elements it can have utmost 5 elements, and we could also know what is the memory allocated for an array. how do we know it in perl
3. how many bytes does a scalar , array, list and hashes occupy.
though most of the questions are elementary, but iam unable to get answers for these from the other books and hence i request the board members to clarify it
with regards
rathankar
Well, the answer to your first question is, it depends on the amount of memory in your system and what you are storing in your arrays.

To find out ( through your own research) how much memory is used by perl variables (arrays, hashes, etc), I did a search on CPAN and discovered the module Devel::Size which does something similar to what you are asking.

Regards,

Jeff
Oct 7 '07 #2
KevinADC
4,059 Expert 2GB
Perl does not put any limits on how much memory variables can store. They will use all available memory if necessary. In general you almost never worry about memory issues with perl unless you are processing large amounts of data. By defining your variables lexically perl frees up memory as variables go out of scope. The allocaion of memory to arrays is not very efficient though if my own memory serves me. In the name of faster processing perl allocates large chunks of memory to arrays instead of adding memory as necessary when an array grows larger.

You might want to ask ths question on www.perlmonks.com where there are more members with mor experience with these type of developer questions.
Oct 7 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: hall | last post by:
I have a question regarding where memory is allocated when arrays are created. I'll illustrate this by example. I may be wrong on some details, do feel free to correct me. The code piece: int...
3
by: Anoop | last post by:
Hi guys i have a piece of code main() { switch(...) { case 1: {
21
by: Stephan | last post by:
why does the following code not work???? after compiling and running it will just say killed after all my memory filled up any suggestions? #include <iostream> using namespace std; void...
5
by: Alan Howard | last post by:
We're getting "ERROR (0x8007000E) Not enough storage is available to complete this operation" errors on a fairly large, busy ASP/SQL Server web site. The error is being thrown on a line calling...
94
by: smnoff | last post by:
I have searched the internet for malloc and dynamic malloc; however, I still don't know or readily see what is general way to allocate memory to char * variable that I want to assign the substring...
53
by: fdmfdmfdm | last post by:
This is an interview question and I gave out my answer here, could you please check for me? Q. What are the memory allocation for static variable in a function, an automatic variable and global...
11
by: mast2as | last post by:
This question has been posted to this forum before and I read the thread but found that the answers were perhaps imcomplete, so I am trying again. Whenever I am creating objects I would like to...
27
by: George2 | last post by:
Hello everyone, Should I delete memory pointed by pointer a if there is bad_alloc when allocating memory in memory pointed by pointer b? I am not sure whether there will be memory leak if I do...
50
by: arunajob | last post by:
Hi all, If I have a piece of code something like this void main(void) { char * p1="abcdefghijklmn"; ............................................. }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.