I have been trying to submit solution to a question since yesterday but still in vain. I am getting a run-time error for larger testcases. On researching about this runtime error I came to know that it is caused by using excessive memory. I have an array of size <=10^6
and a vector of <=10^12
integer pairs. Should this cause stack overflow, especially in the case of the vector?
PS: I have used C++ STL many times but never faced memory overflow in these limits.
Asked
Active
Viewed 1,602 times
0

yobro97
- 1,125
- 8
- 23
-
4*"vector of <=10^12 integer pairs"* That's up to 8TB of memory. You'll need to improve your algorithm. (Or rent some computer that has that kind of RAM, but that's most likely not the point of the exercise. ;) ) – Baum mit Augen Feb 03 '17 at 15:45
-
10^12 integers are 4000GB. – Leandros Feb 03 '17 at 15:45
-
Possible duplicate of [When does a process get SIGABRT (signal 6)?](http://stackoverflow.com/questions/3413166/when-does-a-process-get-sigabrt-signal-6) – Werner Henze Feb 03 '17 at 15:48
-
@BaummitAugen.....thank you....I completely forgot that 10^12 is square of 10^6 not twice :P – yobro97 Feb 03 '17 at 15:49
-
@WernerHenze....I mentioned in the question about `reserach on such error`....actually meant the question u mentioned ...................:) – yobro97 Feb 03 '17 at 15:51
-
SIGABRT got nothing to do with c++ or STL, it's platform dependent (POSIX) way to handle catastrophic failure. you're not only out of stack, you most likely out of addressable area of memory at all. a) you should compartmentalize if you actually need this large amount of data, you cant process t at once, unless you have some supercomputer b) very large data structures never should be storage with automatic life span – Swift - Friday Pie Feb 03 '17 at 15:51
-
@Leandros 10^12 _pairs_ of integers, it's 8TB on system with 32bit int – Swift - Friday Pie Feb 03 '17 at 15:57
1 Answers
0
Most likely you're running out of memory (unless your system has >8TB of virtual memory) and std::bad_alloc
is thrown. An unhandled exception will cause a call to terminate()
which will call abort()
.
If you really want to debug this, run your program under gdb
, you should see something like:
Program received signal SIGABRT, Aborted.
Then you can type bt
to see the stack trace.

rustyx
- 80,671
- 25
- 200
- 267