473,386 Members | 1,745 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,386 software developers and data experts.

How to find the Maximum size of static data?

Hi all,
how can I figure out what is the maximum size of data that can
be allocated in static area on a particular architecture. I am using
g++ on 64 bit Intel architecture and when I create a static array of
size 2^20, then my program seg-faults.

Thanks,
Divick

Nov 22 '05 #1
6 2630
Divick wrote:
Hi all,
how can I figure out what is the maximum size of data that can
be allocated in static area on a particular architecture.
Ask somebody who knows about your specific platform.
when I create a static array of
size 2^20, then my program seg-faults.


If thing this is because you are having C++ language problem, post your
code so everybody can see exactly what you're trying to do.

-Brian

Nov 22 '05 #2
What if I am doing the same thing on say Windows XP 32 bit OS?
Essentially what is the way to know the maximum size of static array on
any platform.

My code is pretty simple as shown below. If I change the size to
1000000 then I don't get a crah while if I simply compile and run this
on 64 bit linux then I get a crash.

#define MAX_SIZE 1048576
//#define MAX_SIZE 1000000

int main()
{
int ** arrayOfAddresses = new int *[MAX_SIZE];
}

Thanks,
Divick

Nov 22 '05 #3
Opps ..I posted the wrong code....the actual code is

#define MAX_SIZE 1048576
//#define MAX_SIZE 1000000

int main()
{
int arrayOfAddresses[MAX_SIZE];

}

Nov 22 '05 #4
Divick wrote:
Opps ..I posted the wrong code....the actual code is

#define MAX_SIZE 1048576
//#define MAX_SIZE 1000000

int main()
{
int arrayOfAddresses[MAX_SIZE];

}


There's no answer to your question. Every compiler and/or platform is
going to be different. Code that needs to create arrays this big is
flawed code. Why do you think you need an array this big?

john
Nov 22 '05 #5
Divick wrote:
Opps ..I posted the wrong code....the actual code is

#define MAX_SIZE 1048576
//#define MAX_SIZE 1000000

int main()
{
int arrayOfAddresses[MAX_SIZE];

}


That's not static data. That's allocated on the stack. You're
allocating 4MiB on the stack. Your system can't handle that, and
crapped out with a stack overflow.
Nov 22 '05 #6
Yeah you are right , but I just had this query. I just wrote a small
test code and tried to allocate the data on the stack and later
realized and modified to be allocated on heap. Still my question
remains unsolved. Sometimes, you want to create some data on the stack,
rather than on the heap , and that led to my question.

anyways thanks,
divick

Nov 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: eggie2486 | last post by:
What is the maximum size of an array? I tried to edit an extremely large array for a magic square, for example, array, and when I ran the program, it would not display the array. I changed the...
6
by: Jon Jagger | last post by:
I was thinking about how you can only use sizeof to find the size of an unmanaged type. I started to wonder if there was a way to find the size of a managed object and came up with the following....
4
by: Gregory Hassett | last post by:
Hello, Does anyone know how to get the maximum size of a datagram for a UDP Socket created via .NET's System.Net.Sockets.Socket class? Thanks!
2
by: Chris Fink | last post by:
This should be relatively simple but I am unable to find an asp:button tag in a datalist footer. I have tried it numerous ways including the FindControl method from the many events that the...
4
by: cdrom205 | last post by:
static void MDString ( unsigned char *input) { MD5_CTX context; unsigned char digest; unsigned int len = sizeof(input);//strlen (const char*) md5.MD5Init (&context); md5.MD5Update...
29
by: garyusenet | last post by:
I'm trying to investigate the maximum size of different variable types. I'm using INT as my starting variable for exploration. I know that the maximum number that the int variable can take is:...
43
by: Frodo Baggins | last post by:
Hi all, We are using strcpy to copy strings in our app. This gave us problems when the destination buffer is not large enough. As a workaround, we wanted to replace calls to strcpy with strncpy....
2
by: Adam Teale | last post by:
hey guys Is there a builtin/standard install method in python for retrieving or finding out an image's dimensions? A quick google found me this:...
2
choke
by: choke | last post by:
I need to write a function in devc++ that creates an array of n integers, each element is equal to n*n+i*i-n*i where i is from 0 to n-1 as the array index. Within the same function I need to find...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.