Memory Size
-
Hello...I'm declaring a class array of size 80,000,000...when compiling there is an error that the size exceeds the allowed one and the program may not run. I tried but it really does not work..it says that the program is not a win32 application. My solution is to declare the class array dynamically: myclass1 = new myclass[size] When I tried with this there is no memory allocated and the program aborts. As myclass has some double data and other classes embedded, I guess I need to overload the operator new so to create the needed space. Can anyone help me how to do this, assuming the class is defined as: class myclass{ public: myclass2 curr_data2; myclass3 curr_data3; myclass2 new_data4; myclass3 new_data5; } and the other classes class myclass2{ public: double x; double y; double z; } class myclass3{ public{ double motionX; double motionY; double motionZ; } Thanks, Eric Manuel Rosales Pena Alfaro PhD student Unversity of Essex Wivenhoe Park Colchester, CO4 3SQ Essex, Uk email: emrosa@essex.ac.uk tel: +44-01206-87311
-
Hello...I'm declaring a class array of size 80,000,000...when compiling there is an error that the size exceeds the allowed one and the program may not run. I tried but it really does not work..it says that the program is not a win32 application. My solution is to declare the class array dynamically: myclass1 = new myclass[size] When I tried with this there is no memory allocated and the program aborts. As myclass has some double data and other classes embedded, I guess I need to overload the operator new so to create the needed space. Can anyone help me how to do this, assuming the class is defined as: class myclass{ public: myclass2 curr_data2; myclass3 curr_data3; myclass2 new_data4; myclass3 new_data5; } and the other classes class myclass2{ public: double x; double y; double z; } class myclass3{ public{ double motionX; double motionY; double motionZ; } Thanks, Eric Manuel Rosales Pena Alfaro PhD student Unversity of Essex Wivenhoe Park Colchester, CO4 3SQ Essex, Uk email: emrosa@essex.ac.uk tel: +44-01206-87311
A quick calculation yields that for the array alone, the program will use approximately 3.6G of memory. I think you need to re-think your array size to bring it down to a much smaller number. Chris Meech "what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002. "Microsoft hasn't ever enforced its patents. Apparently they keep them for defensive reasons only. Or, they could be waiting 'til they have a critical mass of patents, enforce them all at once and win the game of Risk that they're playing with the world." Chris Sells Feb 18, 2003.
-
Hello...I'm declaring a class array of size 80,000,000...when compiling there is an error that the size exceeds the allowed one and the program may not run. I tried but it really does not work..it says that the program is not a win32 application. My solution is to declare the class array dynamically: myclass1 = new myclass[size] When I tried with this there is no memory allocated and the program aborts. As myclass has some double data and other classes embedded, I guess I need to overload the operator new so to create the needed space. Can anyone help me how to do this, assuming the class is defined as: class myclass{ public: myclass2 curr_data2; myclass3 curr_data3; myclass2 new_data4; myclass3 new_data5; } and the other classes class myclass2{ public: double x; double y; double z; } class myclass3{ public{ double motionX; double motionY; double motionZ; } Thanks, Eric Manuel Rosales Pena Alfaro PhD student Unversity of Essex Wivenhoe Park Colchester, CO4 3SQ Essex, Uk email: emrosa@essex.ac.uk tel: +44-01206-87311
The default stack size is 1MB, hence the compiler error. Allocating much more than that (100s of MBs) from the heap is possible but I would still question the need. That's not to say that a need doesn't actually exist, but to just nonchalantly ask the OS for GBs, or even MBs, of memory all at once is questionable.
-
Hello...I'm declaring a class array of size 80,000,000...when compiling there is an error that the size exceeds the allowed one and the program may not run. I tried but it really does not work..it says that the program is not a win32 application. My solution is to declare the class array dynamically: myclass1 = new myclass[size] When I tried with this there is no memory allocated and the program aborts. As myclass has some double data and other classes embedded, I guess I need to overload the operator new so to create the needed space. Can anyone help me how to do this, assuming the class is defined as: class myclass{ public: myclass2 curr_data2; myclass3 curr_data3; myclass2 new_data4; myclass3 new_data5; } and the other classes class myclass2{ public: double x; double y; double z; } class myclass3{ public{ double motionX; double motionY; double motionZ; } Thanks, Eric Manuel Rosales Pena Alfaro PhD student Unversity of Essex Wivenhoe Park Colchester, CO4 3SQ Essex, Uk email: emrosa@essex.ac.uk tel: +44-01206-87311
easy dude, that's pretty nuts. are you sure you NEED 80 MILLION of your class thingy's, or are you just allocating that many "to be on the safe side" ? I suggest you look into std::vector. It just may provide all the answers you seek. i.e., if you need another one of your classes, just do something like:
std::vector<MyClass*> vpMyClass;
for(int i=0; i<iSomeNumberOfNeededClasses; i++)
vpMyClass.push_back(new CMyClass);just remember to delete everything and empty the vector when you're done. - Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb