Heap Limit?

This is a discussion on Heap Limit? within the C++ Programming forums, part of the General Programming Boards category; I'm writing a fairly large game program and I just finished a section and was planning on updating the current ...

  1. #1
    Novice C++ Programmer
    Join Date
    Nov 2003
    Posts
    96

    Heap Limit?

    I'm writing a fairly large game program and I just finished a section and was planning on updating the current release. But when I compiled it in MSVC++ 6 I got this error:

    fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit
    I have barely any MSVC++ 6 experience. Assistance would be much appreciated Thanks.

  2. #2
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    http://msdn.microsoft.com/library/de...html/C1076.asp


    that should help you a bit, there's many different things which could cause this.

  3. #3
    Novice C++ Programmer
    Join Date
    Nov 2003
    Posts
    96
    Ahhhhhh. Thanks. I think I know what it is. I have a huge if else statement series in my program. I'll just create a seperate function for it and place it in a seperate file. Thanks again.
    Last edited by Padawan; 04-11-2004 at 02:18 AM.

  4. #4
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    just a comment.. by waht you are saying it looks like you are controlling the flow of the entire game using if else... am i right????

  5. #5
    Novice C++ Programmer
    Join Date
    Nov 2003
    Posts
    96
    Quote Originally Posted by vasanth
    just a comment.. by waht you are saying it looks like you are controlling the flow of the entire game using if else... am i right????
    No. Just which abilities/moves the enemy uses. And the move list is so huge, it's confused the program.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,418
    Seems to me like you're trying to compile the whole project as a single source file, because you have
    #include "class.cpp"
    for all the classes you have, instead of putting all the source files in the project.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Novice C++ Programmer
    Join Date
    Nov 2003
    Posts
    96
    Quote Originally Posted by Salem
    Seems to me like you're trying to compile the whole project as a single source file, because you have
    #include "class.cpp"
    for all the classes you have, instead of putting all the source files in the project.
    Actually I have 4 header files and 2 CPP files but I think I've almost gotten this solved.

  8. #8
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    is there any way to simplify your coding using constants and loops?

    example:

    constants.h:
    Code:
    enum ItemTypes { POTION, BOTTLE, BOX, THING, TABLE, NUMITEMS };
     
    const char ItemNames[NUMITEMS][32]=
    {
    	  "Potion",
    	  "Bottle",
    	  "Box",
    	  "Thing",
    	  "Table"
    };
     
    const int ItemPrices[NUMITEMS]=
    {
    	  50,
    	  25,
    	  5,
    	  1,
    	  20
    };
    game.cpp
    Code:
    #include <iostream.h>
    #include <constants.h>
    
    int main()
    {
    	  cout << "Items you can purchase and their prices: " << endl;
    	  for(int a=0;a<NUMITEMS;a++)
    			  cout << ItemNames[a] << "  Gold: " << ItemPrices << endl;
    	  getch();
    	  return 0;
    }
    might be some bugs in that code, i just now wrote it, but you should get what i'm trying to say. This allows you to easily add new items just by adding one more ID and updating the names and prices. Kind of like a database. I'm not sure if you've already done this or know about it, cuz i haven't seen your code, but it sounds like you could benefit from doing something like this...Most programs shouldn't really have that many if-else statements as to overflow the stack

    or just use a switch statement

  9. #9
    Novice C++ Programmer
    Join Date
    Nov 2003
    Posts
    96
    Yeah I see what you are saying. The toughest part for me is the fact that I am just creating a 'game mod' so to speak. Or basically I am trying to make complete the work of someone else. But I'll try to work all of this out. Thanks a lot for the tips. This has in fact helped me know now, how to deal with larger programs. SO when I make my own I won't make the same mistakes that are in this one.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Heap limit error???
    By sunburnbyRA in forum C++ Programming
    Replies: 6
    Last Post: 04-10-2003, 03:12 PM
  2. hi need help with credit limit program
    By vaio256 in forum C++ Programming
    Replies: 4
    Last Post: 03-31-2003, 11:23 PM
  3. heap question
    By mackol in forum C Programming
    Replies: 1
    Last Post: 11-30-2002, 04:03 AM
  4. heap limit
    By bob20 in forum C++ Programming
    Replies: 6
    Last Post: 04-17-2002, 06:48 AM
  5. internal heap limit
    By Unregistered in forum C Programming
    Replies: 8
    Last Post: 02-05-2002, 08:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21