944,124 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 13587
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Jul 14th, 2007
0

Chess Program

Expand Post »
Hi, I am creating a chess program. I am creating each piece on the board.

But when I try to compile the bishop piece I get this error
FATAL : Out of Memory in function set.

What does this mean?
Similar Threads
Reputation Points: 31
Solved Threads: 3
Junior Poster
krnekhelesh is offline Offline
127 posts
since Jul 2007
Jul 14th, 2007
0

Re: Chess Program

i did a google on the error you posted but didnt get much (put it in quotes to hope to find someone with the same error)

doing a little rearranging this was the best i could find

Quote ...
Memory Leaks


A memory leak is a loss of available memory space. This occurs when dynamic data are no longer needed in the program, but the memory that is used has not been deallocated. It can also occur when an assignment is made to a pointer variable that already holds the address of an allocated area.
Each time a memory leak occurs, the application drains the available memory pool. Even in virtual-memory systems, the gradual increase in application size can result in performance degradation that affects the entire system. Eventually, this performance degradation can lead to a fatal out-of-memory condition that may be encountered by an application unrelated to the one that caused the memory leak in the first place.
Tip: make sure you match allocation calls with deallocation calls when doing unit testing, particularly where there might be an early return from a function where dynamic data was allocated. It's also essential to check, before assigning to a pointer, that the memory accessible via that pointer is freed prior to the assignment or made accessible some other way.
Reputation Points: 152
Solved Threads: 39
Master Poster
Killer_Typo is offline Offline
778 posts
since Apr 2004
Jul 14th, 2007
0

Re: Chess Program

Quote ...
Memory Leaks


A memory leak is a loss of available memory space. This occurs when dynamic data are no longer needed in the program, but the memory that is used has not been deallocated. It can also occur when an assignment is made to a pointer variable that already holds the address of an allocated area.
Each time a memory leak occurs, the application drains the available memory pool. Even in virtual-memory systems, the gradual increase in application size can result in performance degradation that affects the entire system. Eventually, this performance degradation can lead to a fatal out-of-memory condition that may be encountered by an application unrelated to the one that caused the memory leak in the first place.
Tip: make sure you match allocation calls with deallocation calls when doing unit testing, particularly where there might be an early return from a function where dynamic data was allocated. It's also essential to check, before assigning to a pointer, that the memory accessible via that pointer is freed prior to the assignment or made accessible some other way.
How do get the memory back?
Reputation Points: 31
Solved Threads: 3
Junior Poster
krnekhelesh is offline Offline
127 posts
since Jul 2007
Jul 14th, 2007
0

Re: Chess Program

Suppose I have an array

char board[8][8]; ( This represents the chess board)

I want to store the PieceNo at each box on this board so that the computer can Identify which piece is there at that particular box.

For eg suppose at board[0][2] there is a white pawn. I want to store the value WP1 at the location board[0][2].

How can I do that?? Please help me.
Reputation Points: 31
Solved Threads: 3
Junior Poster
krnekhelesh is offline Offline
127 posts
since Jul 2007
Jul 14th, 2007
0

Re: Chess Program

> But when I try to compile the bishop piece I get this error
> FATAL : Out of Memory in function set.
Just so that we're all clear on this, this happens when you're compiling the code right?

Or does it mean the code has compiled OK, and this is what you get when you run the code.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Jul 14th, 2007
0

Re: Chess Program

I get it when I try to compile the code.
Reputation Points: 31
Solved Threads: 3
Junior Poster
krnekhelesh is offline Offline
127 posts
since Jul 2007
Jul 14th, 2007
0

Re: Chess Program

The most likely cause is that your source file is too big. This is either because you only have one source file, and it contains all the code, or you have many source files, but they're all #include'ed in a since file which is then compiled.
The solution is to split the code up into separately compiled modules.

The next most likely cause is that you're using some ancient 16-bit fossil compiler, and you're using the wrong memory model. If your code (or data) exceeds 64K, and you've chosen the wrong memory model, then the program will no longer fit in memory.
The solution is to use the correct memory model for your project (see your compiler manual pages for details of how to do that).
A better solution is to use a modern 32-bit compiler and join the rest of the real world.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Jul 14th, 2007
0

Re: Chess Program

Quote ...
The solution is to split the code up into separately compiled modules.
Do you mean into different header files. Like some functions into different header files?
Reputation Points: 31
Solved Threads: 3
Junior Poster
krnekhelesh is offline Offline
127 posts
since Jul 2007
Jul 14th, 2007
0

Re: Chess Program

Can you tell any 32 bit compiler which supports graphics.h and functions like circle(x,y,rad); stuff like that.

Because for the chess program I require those.
Reputation Points: 31
Solved Threads: 3
Junior Poster
krnekhelesh is offline Offline
127 posts
since Jul 2007
Jul 14th, 2007
0

Re: Chess Program

Yes, drop the idea graphics.h as being the only thing which can do graphics.

For example, dev-c++ easily integrates with http://www.libsdl.org/

> Do you mean into different header files. Like some functions into different header files?
Yes, like you have
board.c - the implementation of a chess board
board.h - the interface to the chess board
pieces.c -
pieces.h
main.c - brings everything together.
The project file would contain 3 source files and two header files.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Developing a class that works with money C++
Next Thread in C++ Forum Timeline: exact double numbers





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC