LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

array exceeds 2147483647

I have a global struct that holds data.  I predefine in a .h file  the struc to hold the max amount of data possible before runtime, but I get an error that it exceeds 2G?

 

//Run Data Storage
#define MAX_BYTES_PER_CHANNEL 3600000  //3.6Meg bytes Over 1 hour record time for Hard channel
#define MAX_RUNS 3


struct RUN_NUMBER
{
 int run_file; 
 unsigned long hard_record_cnt;
 unsigned long hard_buffer_cnt;
 unsigned long can_record_cnt;
 unsigned long can_buffer_cnt; 
 int channel_checkbox[MAX_CHANNELS];
 char run_file_name[MAX_PATHNAME_LEN];
 float channel_buf[MAX_CHANNELS][MAX_BYTES_PER_CHANNEL];  
};

extern struct RUN_NUMBER RUN_NUMBER[MAX_RUNS];

  

Apparently this is a windows error because windows only allows an application to have up to 2g of space.

 

What I really want to do is define the array size MAX_BYTES_PER_CHANNEL at runtime based on the size of the file I want to read.

 

I assume I am going about this the wrong way.  I do want to be able to access this structure globally, if possible, but I need to create its size at runtime.

 

How can I do this?  Only define a pointer to the array in the struct and then defien the array size later?

 

 

 

0 Kudos
Message 1 of 3
(3,162 Views)

My first approach would be to change your immense global structures, and instead allocate memory at run-time (using calloc()), but this will not overcome the basic problem of your application trying to use too much memory. Without knowing the details of what you are trying to do it is difficult to suggest alternative approaches. You mentioned reading data from a file - why then do you need to have all the values in memory, if they exist in a file?

 

JR

0 Kudos
Message 2 of 3
(3,145 Views)
I have created changed data format to allocate needed memory at run time and that fixed the issue.  THe reason I need to load all the data into memroy is so that I can minipulate it faster during runtime.  To keep trying to reload the data fro the file slows processing down to much.
0 Kudos
Message 3 of 3
(3,138 Views)