Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - memloss() reports memory leaks in a program http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 memloss()           Reports memory leaks in a program
------------------------------------------------------------------------------
 Declaration
   memory.hdr

 Syntax
   proc memloss extern
   param value uint uInfo

 Arguments
   uInfo is an arbitrary numeric value that is displayed by the function.

 Return
   None.

 Description
   The memloss() function is a debugging aid that can be used
   in a developed application to track memory leaks.

   Issue a call to memloss() at the very beginning of the program,
   preferably before any other instruction. The current memory status
   is recorded internally. Then call memloss() once again at the very
   end of the application, and at all alternate exit points.

   The function compares the current memory status with the recorded
   start up value. If the amount of free memory is less than the original
   then a visual alert appears on the screen. If no memory loss is
   detected, then memloss() returns without screen output.

   The uInfo parameter can be used to distinguish between various exit
   points of the program.

   In the final version of the application it is recommended to remove
   the calls to memloss(), due to its overhead.

 Example
   #define EXAMPLE_MEMORY
   #include example.hdr

   // For the final version of the program, the application would be compiled
   // like force -DPRODUCTION test.prg
   
   proc Test_memloss
   #ifndef PRODUCTION
      memloss( 0 )
   #endif
   savescreen()         // save the screen...
   
   wait                 // here would be the body of application
   
   // restorearea()     // ...but "forget" to restore it
   #ifndef PRODUCTION
      memloss( 1 )
   #endif
   endproc

   proc main
   Test_memloss()
   endproc

See Also: coreleft()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson