s**b 发帖数: 169 | 1 cygwin下,运行a.out,显示segmentation fault, (core dumped),
possibly due to stack overflow(underflow?).
最大的数组 double 20000*16。其他的可以忽略不计。
winxp, 1.5G |
c*******e 发帖数: 8624 | 2 unlikely
【在 s**b 的大作中提到】 : cygwin下,运行a.out,显示segmentation fault, (core dumped), : possibly due to stack overflow(underflow?). : 最大的数组 double 20000*16。其他的可以忽略不计。 : winxp, 1.5G
|
s**b 发帖数: 169 | 3 那是不是cygwin对这个支持不太好?
【在 c*******e 的大作中提到】 : unlikely
|
e***e 发帖数: 3872 | 4 数组是局部变量?
【在 s**b 的大作中提到】 : cygwin下,运行a.out,显示segmentation fault, (core dumped), : possibly due to stack overflow(underflow?). : 最大的数组 double 20000*16。其他的可以忽略不计。 : winxp, 1.5G
|
s**b 发帖数: 169 | 5 全局变量
【在 e***e 的大作中提到】 : 数组是局部变量?
|
e***e 发帖数: 3872 | 6 如果程序只有这个大的数组,当然有些简单访问,比如遍历累计之类的,
编译运行都没问题。
【在 s**b 的大作中提到】 : 全局变量
|
s**b 发帖数: 169 | 7 没看懂你说得和我问得有什么联系?
【在 e***e 的大作中提到】 : 如果程序只有这个大的数组,当然有些简单访问,比如遍历累计之类的, : 编译运行都没问题。
|
f*******a 发帖数: 80 | 8 how do you allocate memory for the data? It is not a limitation of CYGWIN.
If you are using malloc in C, notice there is a default stack size for each
program. You cannot claim for a size greater than the default size by
specifying a flag in gcc, which allows you to specify the stack size. Check
gcc manual.
However, I recommand to use the data structure "vector" in C++ and use g++.
vector gives the freedom for dynamic memory allocation.
【在 s**b 的大作中提到】 : cygwin下,运行a.out,显示segmentation fault, (core dumped), : possibly due to stack overflow(underflow?). : 最大的数组 double 20000*16。其他的可以忽略不计。 : winxp, 1.5G
|
s**b 发帖数: 169 | 9 I just use an array x[size][size], where size is some big number, but
should not exceed my physical memory. The same code cna run under linux
without any problem.
each
Check
.
【在 f*******a 的大作中提到】 : how do you allocate memory for the data? It is not a limitation of CYGWIN. : If you are using malloc in C, notice there is a default stack size for each : program. You cannot claim for a size greater than the default size by : specifying a flag in gcc, which allows you to specify the stack size. Check : gcc manual. : However, I recommand to use the data structure "vector" in C++ and use g++. : vector gives the freedom for dynamic memory allocation.
|
f*******a 发帖数: 80 | 10 You solution is not sufficient. For instance, if your machine has 1G of
memory, the OS will not allow you to use all of them.
when you run a program, a stack with a finite size is created automatically.
if x[size][size] exceeds this default size of the stack, you will receive
the notorious segmentation fault. (This default stack size might vary among
platforms, which explains why your code runs in linux.) One way to work
around this problem is to specify a flag to gcc when you compile the proble |
|
|
s**b 发帖数: 169 | 11 under cygwin, i try to set stacksize, but it always says
something like stacksize cannot be changed.
I have uninstalled cygwin, so I cannnot re-run the code.
automatically.
among
problem
【在 f*******a 的大作中提到】 : You solution is not sufficient. For instance, if your machine has 1G of : memory, the OS will not allow you to use all of them. : when you run a program, a stack with a finite size is created automatically. : if x[size][size] exceeds this default size of the stack, you will receive : the notorious segmentation fault. (This default stack size might vary among : platforms, which explains why your code runs in linux.) One way to work : around this problem is to specify a flag to gcc when you compile the proble
|
f*******a 发帖数: 80 | 12 i used
g++ -Wl,--stack,10000000 -g funnyhaha.cpp |
s**b 发帖数: 169 | 13 i use similar parameters and have the mentioned error.
I can only change stacksize in a range, ohterwise it will give
some kind of warning by cygwin.
not sure the detail.
【在 f*******a 的大作中提到】 : i used : g++ -Wl,--stack,10000000 -g funnyhaha.cpp
|
f*******a 发帖数: 80 | 14 you cannot allocate all the memory by this static memory allocation. Use
malloc() for dynamic memory allocation. This will give you much more space
than what you can achieve with specifying stack size.
【在 s**b 的大作中提到】 : i use similar parameters and have the mentioned error. : I can only change stacksize in a range, ohterwise it will give : some kind of warning by cygwin. : not sure the detail.
|
s**b 发帖数: 169 | 15 you mean in the code?
anyway, it can run under linux but not cygwin,
so i want to know if there is anyway to correct this problem.
【在 f*******a 的大作中提到】 : you cannot allocate all the memory by this static memory allocation. Use : malloc() for dynamic memory allocation. This will give you much more space : than what you can achieve with specifying stack size.
|