This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Big object allocation problem
- To: <gcc at gcc dot gnu dot org>
- Subject: Big object allocation problem
- From: "Thomas van Gulick" <list at utumno dot student dot utwente dot nl>
- Date: Tue, 28 Sep 1999 04:15:21 +0200
Here's another memory question, why can't I do this without killing the
process?
class test {
public:
test(void) { memset(buffer,0,sizeof(buffer)); };
private:
char buffer[1024*1024*1024];
};
class dummy : public test {};
void main(void) {
try {
dummy *ptr = new dummy;
delete dummy;
} catch(...) {
cout << "exception\n";
}
}
It segfaults on the memset (of course, buffer can't exist, I really haven't
got
that amount of memory), but why can it get to that point anyway? Why is my
constructor called when there is not even enough memory to store all my
variables?
The buffer thing is an example. Don't tell me I should dynamically allocate
it; for this buffer thing it might be reasonable, but what about 4 unsigned
longs
when there are only 2 bytes of free memory?
Thomas
--