

InterviewSolution
1. |
Solve : C++ 6.0 internal heap limit reached ?? |
Answer» Ran into a minor issue with my program where I have reached the heap limit and I am not sure how to fix this. The message when trying to compile states "use /Zm to specify a higher limit", and I am not sure if I should adjust this limit which I have never had to do before, or MAKE the program open -> write appending -> close multiple times instead of just opening at the beginning of the program and then closing at the end. Adding open and close statements which I would have expected to clear the heap, the compiler also does not like. I also tried closing the file earlier in the program and then declare a new myfile2 vs myfile, thinking that it would use a new heap with a different function identifier, but that it also seems to lot like ofstream myfile2; Here is the program without the additional 300+ write to files as commented in the code below. Code: [Select]#include<IOSTREAM> #include<fstream> using namespace std; int main() { ofstream myfile; myfile.open("Config.conf",ios::app); // Over 300 config settings to write to file, with just 2 shown here for example myfile<<"DataDir = \".\"\n"; myfile<<"LogsDir = \"\"\n"; myfile.close(); return(0); } Here is the compiler error I get that I have never run into before. Quote --------------------Configuration: Project1 - Win32 Debug--------------------http://msdn.microsoft.com/en-us/library/aa278580%28v=vs.60%29.aspx Quote Note In most cases, use of this compiler option is not necessary. Use it if compiling your program causes error message C1076: "compiler limit : internal heap limit reached."Thanks again BC I have made large programs before and never ran into this before and assumed that because I know C++, but I am no master of C++, that it might be my technique that was causing this in which I needed to tweak my code to work within the default limits. The link you pointed me to shows me that its a RARE, but known heap size issue and I obviously just needed to increase it. I think the LAST time I had a similar problem it was way back 25+ years ago when I exceeded the 64k limit of GW-Basic when writing a very large video game, that never came to be because the 64k was like hitting a wall. I suppose I could have SHORTENED the game and worked hours on end to make it more efficient (smaller), but I gave up on it when hitting that wall. Never thought I would hit a limit with C++ 6.0, but at least unlike GW-Basic, this limit can be adjusted. Since adjusting this heap memory limit, it now compiles correctly. Many Thanks!!! |
|