Chess Program

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jul 2007
Posts: 126
Reputation: krnekhelesh is an unknown quantity at this point 
Solved Threads: 3
krnekhelesh's Avatar
krnekhelesh krnekhelesh is offline Offline
Junior Poster

Chess Program

 
0
  #1
Jul 14th, 2007
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?
Ubuntu Linux User #25732
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 759
Reputation: Killer_Typo will become famous soon enough Killer_Typo will become famous soon enough 
Solved Threads: 35
Killer_Typo's Avatar
Killer_Typo Killer_Typo is offline Offline
Master Poster

Re: Chess Program

 
0
  #2
Jul 14th, 2007
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

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.
Dont forget to spread the reputation to those that deserve!
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 126
Reputation: krnekhelesh is an unknown quantity at this point 
Solved Threads: 3
krnekhelesh's Avatar
krnekhelesh krnekhelesh is offline Offline
Junior Poster

Re: Chess Program

 
0
  #3
Jul 14th, 2007
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?
Ubuntu Linux User #25732
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 126
Reputation: krnekhelesh is an unknown quantity at this point 
Solved Threads: 3
krnekhelesh's Avatar
krnekhelesh krnekhelesh is offline Offline
Junior Poster

Re: Chess Program

 
0
  #4
Jul 14th, 2007
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.
Ubuntu Linux User #25732
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Chess Program

 
0
  #5
Jul 14th, 2007
> 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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 126
Reputation: krnekhelesh is an unknown quantity at this point 
Solved Threads: 3
krnekhelesh's Avatar
krnekhelesh krnekhelesh is offline Offline
Junior Poster

Re: Chess Program

 
0
  #6
Jul 14th, 2007
I get it when I try to compile the code.
Ubuntu Linux User #25732
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Chess Program

 
0
  #7
Jul 14th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 126
Reputation: krnekhelesh is an unknown quantity at this point 
Solved Threads: 3
krnekhelesh's Avatar
krnekhelesh krnekhelesh is offline Offline
Junior Poster

Re: Chess Program

 
0
  #8
Jul 14th, 2007
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?
Ubuntu Linux User #25732
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 126
Reputation: krnekhelesh is an unknown quantity at this point 
Solved Threads: 3
krnekhelesh's Avatar
krnekhelesh krnekhelesh is offline Offline
Junior Poster

Re: Chess Program

 
0
  #9
Jul 14th, 2007
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.
Ubuntu Linux User #25732
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Chess Program

 
0
  #10
Jul 14th, 2007
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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 7129 | Replies: 30
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC