home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programming Unleashed / Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso / chap15 / drain / drain.dpr next >
Encoding:
Text File  |  1995-03-21  |  799 b   |  35 lines

  1. program Drain;
  2.  
  3. { Program copyright (c) 1995 by Charles Calvert }
  4. { Project Name: DRAIN }
  5.  
  6. { In protected mode it is not likely that you can
  7.   track exactly how much memory is being expended
  8.   by your program. Nevertheless, the program shown
  9.   here gives you a general feeling for what happens
  10.   if you allocate memory, and then forget to dispose
  11.   it. }
  12.  
  13. uses
  14.   WinCrt;
  15.  
  16. type
  17.   PString = ^String;
  18.  
  19. var
  20.   S: PString;
  21.   i: Integer;
  22.   Start: LongInt;
  23. begin
  24.   Start := MemAvail;
  25.   for i := 1 to 10 do begin
  26.     New(S);
  27.     WriteLn(i, ' => ', MemAvail);
  28.   end;
  29.   WriteLn('=======================');
  30.   WriteLn(' Memory at Start: ', Start, ' bytes');
  31.   WriteLn('Memory Available: ', MemAvail, ' bytes');
  32.   WriteLn('     Memory Lost: ', Start - MemAvail, ' bytes');
  33. end.
  34.  
  35.