Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unwanted Program Termination

Status
Not open for further replies.

TheElusiveYak

Programmer
Feb 8, 2004
19
US
Hey guys, me again..... Im now writing a tile based game, and it is spanned across several units. After a while it got to the point where it said that the program's data segment was to large. So i converted some of the larger variable structures into pointers and from there things compiled fine... yet whenever i create a reference to the pointer (or try to read/write to it, not sure) the program either locks up, or terminates suddenly.... I have no idea how to fix this, should i use more files instead of RAM??? As always any help or advice would be greatly appreciated.
 
Are the structures not exceeding the size of the heap?

Are you remembering to reference each of the pointers where you are wanting to access them as data?

Remember "myptr" accesses the pointer data itself, while "myptr^" accesses the data myptr references.

It sounds like you aren't doing that in some case and are accessing/changing parts of memory that the system OS is using.
 
I just double checked all the pointer references and those are all fine, so im thinking that they are too large for the heap. These are the structures im using,

Code:
tile = array[1..256] of byte;
tileset = array[0..60] of tile;
palette = record
  r, g, b : byte;
end;
paltile = array[1..256] of palette;
palset = array[0..60] of paltile;

Im using the palset and tilesets as variables to hold the byte info and to hold the pallet info for the byte, which i know is grotesquely ineficient, but thats all i could figure out how to do to retain the original colors from the bitmaps.

I don't know if this info proves to be any use, but any help or advice that you can offer will be excellent.
Thank you for your time.
Nick
 
these are all global, they are defined in a unit however, but they are only used in that unit
 
I don't have any more ideas for you unless I can see some more of your actual code.

By my math, your structures you posted shouldn't be anywhere near risking the size of the heap (around 45K a piece).
 
Hey Glenn,

Is there a command to display the heap memory available to hold the program variables? Im wondering if Yak could add something like this to the code so it is displayed as the program runs to see if it explodes at some point.

 
There is. Memavail. If he wanted to, he could do that in a wrapper procedure/function when he does his new() calls. To be safe, he should be checking that anyway.

I'm thinking after he posted the structures that something else is going on somewhere.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top