Hi all.
I create an array using this code: -
//Variables.h
-
extern int *g_x; //x voxel vector
-
extern int *g_y; //y voxel vector
-
extern int *g_z; //z voxel vector
-
extern double ***g_xyz; //voxel contents (i.e. organ values)
-
-
-
-
//LoadFile.cpp
-
#include<string>
-
#include<fstream>
-
#include<iostream>
-
#include<Variables.h>
-
-
using namespace std;
-
-
// Voxel information arrays
-
double ***g_xyz;
-
int *g_x;
-
int *g_y;
-
int *g_z;
-
-
//Some other variable declerations
-
...
-
-
void callLoadFile()
-
{
-
// Ask user for input file information
-
cout << endl << "File to be loaded and array size (*.txt X Y Z): ";
-
cin >> filename >> g_numOfVoxelsX >> g_numOfVoxelsY >> g_numOfVoxelsZ;
-
-
// Create the voxel 3d array
-
g_xyz = new double**[g_numOfVoxelsX];
-
for (i = 0; i<=g_numOfVoxelsX; i++) {
-
g_xyz[i] = new double*[g_numOfVoxelsY];
-
for (j = 0; j<=g_numOfVoxelsY; j++) {
-
g_xyz[i][j] = new double[g_numOfVoxelsZ];
-
}
-
}
-
-
//Rest of code
-
...
-
}
-
When I try and create an array of size 300 by 300 by 300, for example, everything works well. If I try anything larger than 475 by 475 by 475 though, my program crashes.
I've attempted to do some debugging by putting in comments. When I try 512 by 512 by 512, the program crashes at the point where it creates the 1 by 512 by 512.
If I run the compiler in debug mode (I'm using Dev-C++) and step past 1 by 512 by 512 and then let the program go, the array will be created with no problem.
I'm pretty new to C++ programming ... I didn't know if it was a problem of not having time to allocate the space, so I added a wait period - to no resolve. Are there inherent limitations in creating arrays of arbitrary size using this method?
Does anybody have any ideas?
Thanks!
-Michael
4 1506
I might add that I'm using Windows XP, 1.7GHz Duo, 2GB of memory.
Thanks.
Well, I know that creating 512x512x512 entries is 134,217,728 doubles, which takes up 1,073,741,824 bytes (with an 8 byte sized double) - my computer, right now, has only 2,337,832,960 bytes of storage free, which is more than 2 GB (2.17 approx.). Assuming you have some 'stuff' on your computer, you probably don't have enough free memory to handle this much data.
I might add that I'm using Windows XP, 1.7GHz Duo, 2GB of memory.
Thanks.
Hi. When you use the new operator in windows you are asking for a contiguous block of free memory just for your app. In this case (512x512x512) you are asking for 1,073,741,824 bytes of contiguous free memory. Aint gonna happen no matter how much memory you have installed.
I have 4Gb and I would normally run foul of windows at around requests for 800mb. Remember, it is not how much memory you have installed. It is how much contiguous (non interupted, in a row) memory windows can get hold of that counts
If you can't get away with using floats instead of doubles, try creating 2 arrays separately and split the load. I have done that with 5 different splits before and got it to work
Great. I'll try spliting the load up. Thank you for your help!
-Michael
Sign in to post your reply or Sign up for a free account.
Similar topics
by: mortoray |
last post by:
Throughout the PHP manual, and normal code, one finds this construct:
$var = array( ... );
However, as far as I can tell this is quite inefficient, since it
always means two arrays are being...
|
by: Jens Mittag |
last post by:
Hi!
In my code, I have an array of a structure, which I want to save to a
binary file. When the array is just created, everything works fine, but
when I change contents of the array, saving...
|
by: Geoff Cox |
last post by:
Hello,
I am trying to get a grip on where to place the initialization of two
arrays in the code below which was created using Visual C++ 2005
Express Beta 2...
private: static array<String^>^...
|
by: Prince of Code |
last post by:
Hey Guys
Lets assume we have two arrays
one bug array - main array
another user array - sub array
The bug array contains the id of the user to whom the bug is
assigned to.
This Id is present...
|
by: Vijay |
last post by:
With the option strict On set.....
Dim fs As FileStream = File.OpenRead(strFile)
With fs
Dim buffer(fs.Length) As Byte ' <--- Option Strict On disallows implicit
conversions from 'Long' to...
|
by: jayharris |
last post by:
I'm having a ton of trouble initializing a multi-dimensional array
inside a constructor, largely because I don't know the size of the
array until runtime. I have a class that looks like this:
...
|
by: Zytan |
last post by:
I want to make a zero element array. I know that Nothing is not the
same as a zero element array, since I can't get the length of, or
iterate through, an array = Nothing. I could make a zero...
|
by: David Golightly |
last post by:
Quick question for the gurus out there: in ECMAScript, one can create
a new Array object with a length like so:
var animals = new Array(128);
This creates a new Array object with a "length"...
|
by: 8rea |
last post by:
Hello,
I want to make a matrix like this:
System::Drawing::Drawing2D::Matrix^ L;
L=gcnew( System::Drawing::Drawing2D::Matrix::Matrix(rect,plgpts));
System::Drawing::Drawing2D::Matrix^ L;...
|
by: Dan Rumney |
last post by:
I've been taking a look at Douglas Crockford's JSLint.
One of the conventions that it expects is that arrays be created using
literal notation
var arr1 = ;
as opposed to using a constructor...
|
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: 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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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: 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: 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...
| |