Hi,
I have a 2D struct with one of the dimensions having about half a million array elements. It gives me the following error:
"relocation truncated to fit..."
Was wondering how I can fix this problem. I have been looking for a solution, but nothing yet.
I think it is to do with increasing the struct size, if I am right with this, how do I go about doing this ??
Many thanks.
|
Go4Expert Member
|
|
| 17Oct2008,19:48 | #2 |
|
Ok guys, there is something else...
when I have 500,000 elements, it give me the error mentioned above. So when I tried reducing the size (no. of elements) to find a sort of a threshold, I noticed that with a size of 411,000, it still gives me the error but with 410,000 elements, it NO LONGER gives me the error. Q1) Any idea why 410,000 or have any of you experienced this before ? Q2) I have to include about 500,000, so what can be the solution to this ? Thanks again... |
|
Ambitious contributor
|
|
| 17Oct2008,22:07 | #3 |
|
More detail would be useful. Could you show us the struct?
|
|
Go4Expert Member
|
|
| 19Oct2008,04:23 | #4 |
|
For eg., the declaration in the 'C', which is what I am using would look something like:
----------------------------------------------------------- typedef struct { int a,b; } vector c[100][500000]; ------------------------------------------------------------- so as mentioned in my previous post, vector c[100][410000] - works fine vector c[100][411000] - does NOT work fine Now, i do understand that this may be due to high no. of elements, but is there a solution to this other than the simple one of using smaller struct size.. Thanks in advance again. |
|
Ambitious contributor
|
|
| 19Oct2008,05:29 | #5 |
|
I'm assuming C (although it does not have "vectors"!).
This does not work: Code:
#include <stdio.h>
typedef struct MyStruct {
int a, b;
} MyStruct;
int main()
{
MyStruct c[100][500000];
c[0][0].a = 1;
printf("a: %d\n", c[0][0].a);
return 0;
}
Code:
#include <stdio.h>
typedef struct MyStruct {
int a, b;
} MyStruct;
MyStruct c[100][500000];
int main()
{
c[0][0].a = 1;
printf("a: %d\n", c[0][0].a);
return 0;
}
Your 400MB array needs to be declared globally (on the "heap"), or you have to drastically increase your stack space. I'd recommend declaring it globally. |
|
Go4Expert Member
|
|
| 21Oct2008,00:00 | #6 |
|
All understood.
Appreciate it, thanks for the help. |
