473,414 Members | 1,709 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,414 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 4240
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.