checkmem.pas 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. {
  2. $Id$
  3. Copyright (c) 2002 by Pierre Muller
  4. This unit is just used to check that all memory is freed
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************}
  17. Unit CheckMem;
  18. {$i fpcdefs.inc}
  19. Interface
  20. Implementation
  21. Const
  22. EntryMemUsed : longint = 0;
  23. SaveExit : pointer = nil;
  24. Procedure CheckMemory(LostMemory : longint);
  25. var
  26. st : string;
  27. begin
  28. if LostMemory<>0 then
  29. begin
  30. str(LostMemory,st);
  31. Writeln('Memory Lost = ',st);
  32. end;
  33. end;
  34. initialization
  35. EntryMemUsed:=system.HeapSize-MemAvail;
  36. finalization
  37. CheckMemory(system.HeapSize-MemAvail-EntryMemUsed);
  38. end.
  39. {
  40. $Log$
  41. Revision 1.2 2002-11-15 12:23:49 peter
  42. * new unit
  43. }