Hello,
I have a "std::bad_alloc" problem when I try to run a simple C++ program on HP-UX. I don't know if it is a memory limitation or maybe a compiler option that I should use. When my program reaches 700M, it aborts.
I'm using gcc to compile.
This is the source: -
#include <stdio.h>
-
#include <unistd.h>
-
#include <malloc.h>
-
-
int main(int argc, char* argv[] )
-
{
-
int tam=744488960
-
char * c = new char[tam];
-
for (int i=0; i<tam-1; i++)
-
c[i]= 32;
-
return 0;
-
}
-
Do you have any idea on how to solve it?
Thanks in advance.
4 2679
The code runs to completion on my Dell laptop machine.
My guess it's a limit of HP-UX. You might check woth your sysadmin to see if you are allowed that much heap.
Kaio,
HP-UX has a maximum amount of virtual memory that it actually can allocate in addition to any arbitrary limits put on your process.
Back, 15 years ago, I had a program, which illustrated a dynamic memory allocation error in the HP-UX FORTRAN compiler. It would run, continuously consuming heap until my image size was between 78 and 80 Mbytes.
People tried using the ulimit shell command to give the process infinite memory, but to no avail.
What was happening is that the ulimit was working, but I was exhausting nearly all of system memory before my image was aborted.
The total system memory size at the time is/was limited by available physical memory and swap partition space. It's just that back then our computers were slow and stupid. The jitter was caused by the difference in memory allocated to other processes running on the system.
So - ask yourself why you need so much memory, and work accordingly.
Cheers!
Oralloy,
Thanks for your answer. I'd created this simple program just to prove that it is a memory limitation. My real application is much more complex than it.
But, when I compile this simple code as a 64-bit program (the machine is ia64), there is no problem during its execution.
So, this is really a HP-UX and 32-bit program limitation because the same code runs normally on a Linux (32-bit) server.
I'm still trying to find any solution. I can't recompile my application and I need to use more than 700M, as well as all Oracle processes that are running on the same machine.
Kaio,
I understand your frustration. When I was using HP-UX, we just didn't have gigabytes of memory available, so I never ran into the inherent operating system memory allocation limits.
You might want to look at how the O/S allocates memory addresses to find your absolute limits. From what I can see, it looks like the O/S has stripped two bits off the 32 bit address space, and you're sharing what's left with something. But - I may be very wrong, too.
Good Luck!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Asfand Yar Qazi |
last post by:
Hi,
Just wondering, if I do a:
std::set_new_handler(std::terminate)
I won't have to worry about a std::bad_alloc being thrown when I do a
'new ...' or a 'new(nothrow) ...', right?
Its...
|
by: Marcus Kwok |
last post by:
Hello, I am working on cleaning up some code that I inherited and was
wondering if there is anything wrong with my function. I am fairly
proficient in standard C++ but I am pretty new to the .NET...
|
by: Gary Wessle |
last post by:
Hi
I am getting this error when running a very similar code like the
below, it is made for illustration only.
thanks
***************************************
**************** error...
|
by: Mohsen |
last post by:
Hello everyone,
In my program, I have to define many pointers and when I want to
compile my program (in UNIX), it gives me the following error:
terminate called after throwing an instance of...
|
by: schizoid_man |
last post by:
Hi,
I have the following code snippets and I get a std::bad_alloc error
where I think there should be none. I've attached the relevant bits of
the base class, derived class and the .cpp file...
|
by: sndive |
last post by:
Do linux kernels 2.4 and 2.6 have some stash of memory set aside to
handle paging in std::bad_alloc
or ... exception handling code when new or new throws that exception?
How is that handled? Does...
|
by: daroman |
last post by:
Hi Guys,
i've problem with my small C++ programm. I've just small template
class which represetns a array, everything works fine up to
combination with std::string. I did tried it with M$ VC++ and...
|
by: jyothiusha |
last post by:
terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc
Aborted
could anyone help me in this?
//mst.cpp
#include <iostream>
#include <fstream>
|
by: Alerion |
last post by:
Hello everyone,
I've been a regular of this forum but this is my first post, generally I can find the answer to my question already, but this time I'm having a somewhat specific problem.
For...
|
by: upadhyad |
last post by:
Hi everyone !!
i have an interesting problem...hope you people can help.
I am coding in C.
the code is posted below:
here I have a structure with two character vectors.
I have to characters....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |