Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Memory Overflow

NeoLeviathanNeoLeviathan Posts: 5Member
[b][red]This message was edited by NeoLeviathan at 2003-3-16 15:56:14[/red][/b][hr]
Working with turbo pascal, when I tried compiling my latest project I got this error on this line (in my type section):

[code]
MARKERARRAY = ARRAY[1..3, 1..100, 1..100] OF INTEGER;
[/code]

I tried also using PACKED ARRAY, i'm guessing i'm surpassing some DOS memory limit for COM files, is their any solution to this?
Any help is GREATLY appreciated because I don't want to have to make a new way of checking my coordinates.


Comments

  • sweeneysweeney Posts: 117Member
    : [b][red]This message was edited by NeoLeviathan at 2003-3-16 15:56:14[/red][/b][hr]
    : Working with turbo pascal, when I tried compiling my latest project I got this error on this line (in my type section):
    :
    : [code]
    : MARKERARRAY = ARRAY[1..3, 1..100, 1..100] OF INTEGER;
    : [/code]
    :
    : I tried also using PACKED ARRAY, i'm guessing i'm surpassing some DOS memory limit for COM files, is their any solution to this?
    : Any help is GREATLY appreciated because I don't want to have to make a new way of checking my coordinates.
    :
    :
    :
    [code]
    markerarray : array[1..3, 1..100, 1..100] of integer;
    [code]
  • NeoLeviathanNeoLeviathan Posts: 5Member
    "MARKERARRAY" is in my TYPE section, not my VAR section. So the "=" would be correct.

    Either way, I'm using characters rather then integers now, and it works fine... But it'd still be nice if somebody knew why I got the error.
  • zibadianzibadian Posts: 6,349Member
    : "MARKERARRAY" is in my TYPE section, not my VAR section. So the "=" would be correct.
    :
    : Either way, I'm using characters rather then integers now, and it works fine... But it'd still be nice if somebody knew why I got the error.
    :
    Based on the code you gave us, there should nothing wrong. But that is based on the type-declaration. If you have 5 or 6 variables of this type or pass it into a procedure as a parameter, you might get this error. That holds especially true if you are running the program from TP itself.
    If the chars work fine, and you still need to store numbers, you should change them to the byte-type. Another solution is to use the TEMSStream object. This allows you to store the data into the EMS memory. The main advantage is that that object isn't nearly as large as your array. The disadvantage is that it won't work on computers without EMS memory and it slows the program down a little.
  • DexterMagnificDexterMagnific Posts: 35Member
    Array 1..3,1..100,1..100 of integers ...

    Let's calculate the size of that array :

    3 (1st dimension) * 100 (2nd dimension) * 100 (3rd dimension) * 2 (size of each integer) = 60000 bytes.

    OK, that might work. Pascal limits the size of a variable to 65520 bytes.
    but it will not work if you declare more than one array based on that type because pascal limits the size of ALL variables to approximately 64Kb.

    if you want to declare more than one variable based on that type, you must use dynamic, allocations. See GetMem and FreeMem procedures in help.
    DexterMagnigfic at yahoo.fr

  • zibadianzibadian Posts: 6,349Member
    : Array 1..3,1..100,1..100 of integers ...
    :
    : Let's calculate the size of that array :
    :
    : 3 (1st dimension) * 100 (2nd dimension) * 100 (3rd dimension) * 2 (size of each integer) = 60000 bytes.
    :
    : OK, that might work. Pascal limits the size of a variable to 65520 bytes.
    : but it will not work if you declare more than one array based on that type because pascal limits the size of ALL variables to approximately 64Kb.
    :
    : if you want to declare more than one variable based on that type, you must use dynamic, allocations. See GetMem and FreeMem procedures in help.
    : DexterMagnigfic at yahoo.fr
    :
    :
    You can declare more than 1 of these variables, but you can only declare 1 globally and 1 locally per procedure/function. But this doesn't solve the memory overflow problem, since the compiler refuses to compile the program with more than 64KB in global or local variables.
  • NeoLeviathanNeoLeviathan Posts: 5Member
    Thanks for all the help, i'll keep all of this in mind the next time I need to declare any large variables. I think the problem might have been that my compiler was TP version 3.01 alpha that I got from school. I'm using TP7 and everything seems to work alot nicer (v3 wouldn't allow "uses").

    So far my game is working smoothly as expected. I'm making an RPG in PASCAL so I needed many arrays to mark special events such as signs or people, as well as move maps from files to memory. This is my first large project so far, so i'm seeing and using alot of new concepts that I haven't learned at school and aren't in my OLD school books.
Sign In or Register to comment.