I am writting an algorithm that generates very large tables in dynamic
memory on a linux system. These 2 tables are of the order of (30,000 x
30,000). They are being generated by the following code:
std::vector <short int*> table;
for(i=0; i < 30000; i++) {
row = new short int[30000];
table.push_back( row );
}
The algorithm crashes before creating the table. There is also no
feedback from the command line as to why the system crashes. I need to
determine two things:
1) What is the EXACT error that is produced by the system. Is there a
way to create an error log file that lists all errors generated by the
system at the time of the crash. Maybe, for example, it could show that
mmap failed to allocate enough memory, etc.
2) I need a way to predict the amount of memory that will be used by
the system. What size, in bits, would this table be? Is a SHORT INT
16bits when used in the vector class?
I would think that size = (30000)(30000)(16)
Thanks 3 1714
PhoneJack wrote: I am writting an algorithm that generates very large tables in dynamic memory on a linux system. These 2 tables are of the order of (30,000 x 30,000). They are being generated by the following code:
std::vector <short int*> table; for(i=0; i < 30000; i++) { row = new short int[30000]; table.push_back( row ); }
The algorithm crashes before creating the table. There is also no feedback from the command line as to why the system crashes. I need to determine two things:
1) What is the EXACT error that is produced by the system. Is there a way to create an error log file that lists all errors generated by the system at the time of the crash. Maybe, for example, it could show that mmap failed to allocate enough memory, etc.
2) I need a way to predict the amount of memory that will be used by the system. What size, in bits, would this table be? Is a SHORT INT 16bits when used in the vector class?
I would think that size = (30000)(30000)(16)
Thanks
I suspect you're running out of memory, and new is throwing
std::bad_alloc, which you don't appear to catch.
I would try the following:
std::vector <short int*> table;
int i;
try {
for (i = 0 ; i < 30000; ++i)
table.push_back(new short int[30000]);
}
catch (std::exception& e)
{
std::cout << "EXCEPTION: " << e.what << std::endl;
// drop dead here in some clean manner.
}
PhoneJack wrote: I am writting an algorithm that generates very large tables in dynamic memory on a linux system. These 2 tables are of the order of (30,000 x 30,000). They are being generated by the following code:
std::vector <short int*> table; for(i=0; i < 30000; i++) { row = new short int[30000]; table.push_back( row ); }
The algorithm crashes before creating the table.
There is nothing in the code to suggest a problem _except_ if you're
running out of memory. Consider that 30k x 30k x sizeof(short) is only
1800 Mbytes (1.8 Gigabytes). And how much do you have virtual memory
in your process to play with?
There is also no feedback from the command line as to why the system crashes.
Surround your loop with
int i;
try {
<... your loop here ...>
}
catch (std::bad_alloc const& e) {
cout << "ran out of memory on " << i << "th loop\n";
}
I need to determine two things:
1) What is the EXACT error that is produced by the system. Is there a way to create an error log file that lists all errors generated by the system at the time of the crash. Maybe, for example, it could show that mmap failed to allocate enough memory, etc.
Catch proper exceptions.
2) I need a way to predict the amount of memory that will be used by the system. What size, in bits, would this table be? Is a SHORT INT 16bits when used in the vector class?
I would think that size = (30000)(30000)(16)
Yes. Got a calculator?
V
> I am writting an algorithm that generates very large tables in dynamic memory on a linux system. These 2 tables are of the order of (30,000 x 30,000). They are being generated by the following code:
std::vector <short int*> table; for(i=0; i < 30000; i++) { row = new short int[30000]; table.push_back( row );
}
The algorithm crashes before creating the table.
If you run out of memory, new throws an exception. Try to catch it and
to print a message to see if that's the case.
There is also no feedback from the command line as to why the system crashes. I need to determine two things:
1) What is the EXACT error that is produced by the system. Is there a way to create an error log file that lists all errors generated by the system at the time of the crash. Maybe, for example, it could show that mmap failed to allocate enough memory, etc.
Not in standard C++. Ask in a newsgroup supporting your compiler or
system
2) I need a way to predict the amount of memory that will be used by the system. What size, in bits, would this table be? Is a SHORT INT 16bits when used in the vector class?
Depends on the system. Try to do
std::cout << sizeof(short int);
I would think that size = (30000)(30000)(16)
If on your system a short int is 16 bits, that would give you the
number of bits you allocated. You probably want it in bytes.
sizeof(short int) returns the number of bytes:
(30000)*(30000)*(sizeof(short int)).
Jonathan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mike P |
last post by:
I know everything about reference counting and making sure you don't have
large objects lying around. I have also profiled my app with multiple tools.
I know about the fact GC collects memory but...
|
by: sangeetha_b |
last post by:
Hello,
I've writen one simple program to automate some manual process. I've
written that in c program. It works fine so far no problem reported on
this. Last week, i get chance to run my program...
|
by: ira2402 |
last post by:
Hi All,
We are developing sw for a small embedded OS and we have limited
memory.
We are looking for algorithms, links, and articles about this.
The goal is efficient utilization of small amount...
|
by: Duncan Mole |
last post by:
Hi,
This is probably an easy one but it iy first bit of p/invoke. I am trying to
use the following C struct in a call:
typedef struct
{
BYTE SRB_Cmd;
BYTE SRB_Status,
BYTE ...
|
by: ballpointpenthief |
last post by:
If I have malloc()'ed a pointer and want to read from it as if it were
an array, I need to know that I won't be reading past the last index.
If this is a pointer to a pointer, a common technique...
|
by: Johan Tibell |
last post by:
I've written a piece of code that uses sockets a lot (I know that
sockets aren't portable C, this is not a question about sockets per
se). Much of my code ended up looking like this:
if...
|
by: heddy |
last post by:
I have an array of objects. When I use Array.Resize<T>(ref Object,int
Newsize); and the newsize is smaller then what the array was
previously, are the resources allocated to the objects that are...
|
by: Eric |
last post by:
This IS material from a CS class on object oriented programming. It is
NOT my homework.
Consider the following:
struct A {short i; void f () {cout << "A::f()\n";}};
struct B : A {long ...
|
by: Peter Olcott |
last post by:
It looks like System::Collections::Generic.List throws and OUT_OF_MEMORY
exception whenever memory allocated exceeds 256 MB. I have 1024 MB on my system
so I am not even out of physical RAM, much...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |