Results 1 to 6 of 6

Thread: My program has gone crazy

  1. #1

    My program has gone crazy

    I suspect a memory leak, I wonder if the following code might be responsible for this:
    Code:
    const
      b: array[0..12] of Byte = (1, 2, 3, 4, 5, 6, 7,8,9,10,11,12);
    
    procedure readData(var X);
    var
      M: array[0..1] of Integer absolute X;
    begin
      // only read from M no writing here
    end;
    
    procedure DoSmthing;
    begin
      readData(b[2]);
    end;
    I know that when b would be an ordinary array then everything would be okay, but b is a const. Can it cause a memory leak?

    Siim

  2. #2

    My program has gone crazy

    the code you posted does not contain memory leaks that would be apparent to me. A static array can't really leak memory so the problem must be somewhere else but the code you posted is not enough to say where it is.
    Also, can you elaborate on how exactly your program is acting crazy?
    Ask me about the xcess game development kit

  3. #3

    Re: My program has gone crazy

    Quote Originally Posted by siim
    Code:
    const
      b: array[0..12] of Byte = (1, 2, 3, 4, 5, 6, 7,8,9,10,11,12);
    I don't know about a memory leak (perhaps you could post some more code?), however, do you realise you are initialising a 13-element array with only 12 elements?

    (That "absolute" directive is a useful one, I don't remember seeing it before.)
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

  4. #4

    My program has gone crazy

    The 12 elements was typo I made. There are too much code to post it here. But the program just throws EExternalException when I finish running an function:
    Code:
    function DoIt: Boolean;
    begin
    
    end;//<-throws an exception here
    Siim

  5. #5

    My program has gone crazy

    Delphi recognizes the following exception codes:

    ?¢_¬¢ STATUS_INTEGER_DIVIDE_BY_ZERO
    ?¢_¬¢ STATUS_ARRAY_BOUNDS_EXCEEDED
    ?¢_¬¢ STATUS_FLOAT_OVERFLOW
    ?¢_¬¢ STATUS_FLOAT_INEXACT_RESULT
    ?¢_¬¢ STATUS_FLOAT_INVALID_OPERATION
    ?¢_¬¢ STATUS_FLOAT_STACK_CHECK
    ?¢_¬¢ STATUS_FLOAT_DIVIDE_BY_ZERO
    ?¢_¬¢ STATUS_INTEGER_OVERFLOW
    ?¢_¬¢ STATUS_FLOAT_UNDERFLOW
    ?¢_¬¢ STATUS_FLOAT_DENORMAL_OPERAND
    ?¢_¬¢ STATUS_ACCESS_VIOLATION
    ?¢_¬¢ STATUS_PRIVILEGED_INSTRUCTION
    ?¢_¬¢ STATUS_CONTROL_C_EXIT
    ?¢_¬¢ STATUS_STACK_OVERFLOW

    Any exception code that is not on the list above raises an EExternalException.

    As a descendant of EExternal, EExternalException saves the Windows exception record (if there is one) in its ExceptionRecord data structure.

  6. #6

    My program has gone crazy

    Just comment out the code little by little to find out what exactly causes this exception and post that.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •