Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filling a TMemoryStream with just about anything. 1

Status
Not open for further replies.

RossMcIvor

Programmer
Jan 24, 2007
9
GB
Could someone help me,

I want to fill a Memory Location, or some how write to memory in a large chunk, I seam to get a memory stream to save about 10Mb of text but it takes a long time, does anyone know how I could fill a memory location with random values that will not use much cpu and really write the infomation at the speed that memorys max speed might be, say 100mb/s, but I know DDR400 does more than 1mb/s.. could anyone help.
 
If it helps, here's what I mentioned in the other thread:

Code:
  { find out how much real memory we have to work with }
  MS.dwlength := 32;
  GlobalMemoryStatus(MS);
  availphys := MS.dwAvailPhys;
  { adjust down & round down to nearest MB }
  availphys := trunc(availphys * 0.70);
  mbytes := availphys div 1024 div 1024;
  availphys := mbytes * 1024 * 1024;
  { now get memory for process }
  GetMem(memptr, availphys);
  { now start process }
  Label1.Caption := 'Now processing, please wait.';
  Button1.Enabled := false;
  Timer1.Enabled := true;
  { fillchar/readchar logic }
  tcounter := 0;
  repeat
    FillChar(memptr^, availphys, Char(255));
    inc(tcounter);
    Application.ProcessMessages;
  until timer1.enabled = false;
  FreeMem(memptr);
  { report answer here }
  final_speed := (mbytes * tcounter) / 15;
  label1.caption := FloatToStr(final_speed) + ' MB / s.';
  Button1.Enabled := true;
 
I'm not sure how much difference the memory manager would make here, especially in the example (one get, one free). But I will say that dropping an appropriate Fastcode FillChar procedure into the routine above will produce an appreciable change. My Athlon XP 2000+ registered an 80MB/s increase by doing such a thing - probably netting a number somewhat closer to what the memory actually rates.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top