home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 996 of 2,978   
   L D Blake to dontspamme@whydoyouneedmyaddressspa   
   Re: FPC Questions   
   27 Sep 04 16:19:06   
   
   From: not@any.adr   
      
   On Mon, 27 Sep 2004 13:57:07 -0500, Glenn Someone   
    wrote:   
      
   >Agreed with you, taking all memory in a multitasking environment is   
   >bad, although I thought I posted more than just that.  That is why I'm   
   >asking the question about finding out exactly how much memory I have   
   >to work with so I can figure out a happy medium between what would   
   >work in Windows and what would work best for the application.   
      
   And therein lies your mistake!  You are trying to acquire and keep a fixed   
   amount of memory for your program to work in... This simply is *not* necessary   
   anymore.  In fact, for large chunks of memory it's a *bad* thing...   
      
   Where the crossed wires are coming from is that you seem stuck on this idea   
   that you have to somehow magically gain ownership of a big chunk of memory   
   when we are telling you this is no longer good practice.   
      
   From your last set of descriptions I get the impression you are trying to   
   buffer some huge number of data records in memory because you believe that   
   writing and fetching from disk is painfully slow.  This too has changed rather   
   a lot.  IDE burst data speeds of 200 mb/sec are not uncommon and with Raid   
   arrays and sata we can probably double that.  There is nothing slow about   
   random access storage, these days... engineers have been working on it ever   
   since MFM drives came out.  I have a number of POS systems out there, some   
   with 500,000 record inventory files... they work record by record and believe   
   me they are anything but slow.   
      
   Now... about this memory usage thing...   
      
   Look into dynamic arrays...   
   They're the sweetest form of buffering you'll ever find...   
      
      
   		Var   
   			MyBuffer 	: array of MyRecord;   
      
   		procedure AddRecord(NewData : MyRecord;   
   			begin   
   				try   
   					// add space to buffer   
   					setlength(mybuffer,length(mybuffer) + 1);   
   				except   
   					// put buffer on disk   
   					WriteMyBuffer;   
   					// release memory   
   					setlength(mybuffer,0);   
   					// ready for next record;   
   					setlength(mybuffer,1);   
   				end;   
   				// add new data   
   				mybuffer[high(mybuffer)] := NewData;   
   			end;					   
   	   
      
   		Begin   
   			setlength(MyBuffer,1);  // initialize buffering   
      
   		end.   
      
      
   In the above, the array MyBuffer is dynamic.  By adding new records it grows   
   in size (and thus memory usage) until you get an out of memory exception and   
   then writes the data to disk.  A little extra code could be added to write the   
   stuff out if the app is idle for more than a few seconds or when some   
   arbitrary maximum number of records is reached.  The point is that the code is   
   *dynamic* in that the exception can occur after 10 records or a thousand with   
   little or no consequence to your software.   
      
   You mentioned that you can make your program work in about 76k of dynamic   
   variable space... try this...  Trust the Windows disk buffering.  Go record by   
   record, and see what happens.  I'm thinking you'll be pleasantly surprised.   
      
   Download and try the File System Scan on my website.  Note that on most   
   systems it averages about 20 to 30 *megabytes* per second on IDE drives.  On   
   my partner's SATA/RAID/2.6ghz system it can hit 80 mb/s.  This lowly little   
   program has to access the directory before every file and is running on a 32k   
   data buffer!   
      
   Methinks, yer making rather much of nothing at all.   
      
   -----   
   Laura   
      
   (http://www.start.ca/users/ldblake)   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca