Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-09

Caching a big file on memory

8 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Eduardo

Hello:

I have a little problem, i participe in the 'Large Compression Benchmark' (http://cs.fit.edu/~mmahoney/compression/text.html) and need to cache the whole enwik8 file (100MB) on memory but when i try to allocate space for it i get a compiler error, saying that maximum is 64MB (67108864). I tried to use $MEMORY 200000000,500000000 (200MB stack and 500MB heap) and the compiler switches, but no success.

I need all the file on RAM beacause i want to do a BWT, which implies a sort of the 100MB and uses 400 more MB, and doing so from hard disk is very slow. The contest has a time limit of 10 hours on a 1Ghz machine, but i need all speed at BWT/sort phase, so i can spend the time on getting better compression.

Must i touch the system, rtl etc... files and recompile compiler? Or is there another, and simpler, way?

P.D. Of course, my pc has more than 100 MB (1.25 GB)

Reply by email

Jonas Maebe
to Eduardo
Eduardo wrote 7 lines
I have a little problem, i participe in the 'Large Compression Benchmark' (http://cs.fit.edu/~mmahoney/compression/text.html) and need to cache the whole enwik8 file (100MB) on memory but when i try to allocate space for it i get a compiler error, saying that maximum is 64MB (67108864). I tried to use $MEMORY 200000000,500000000 (200MB stack and 500MB heap) and the compiler switches, but no success.

How are you trying to allocate the memory, and for which target operating system are you compiling?

Jonas

Reply by email

Eduardo
to Jonas Maebe
Jonas wrote 12 lines
On 11 Sep 2006, at 18:09, Eduardo wrote: > I have a little problem, i participe in the 'Large Compression >Benchmark' (http://cs.fit.edu/~mmahoney/compression/text.html) and >need to cache the whole enwik8 file (100MB) on memory but when i >try to allocate space for it i get a compiler error, saying that >maximum is 64MB (67108864). I tried to use $MEMORY >200000000,500000000 (200MB stack and 500MB heap) and the compiler >switches, but no success. How are you trying to allocate the memory, and for which target operating system are you compiling?

Oppsss, sorry, I have tried to allocate using pointer, direct array var and pointer to type array

a)
var
     p : pointer of byte;
...
     GetMem(p,100000000); //100 MB
b)
var
     a : array[1..100000000] of byte; //100MB
c)
type
     a = array[1..100000000] of byte; //100MB
     pa = ^a;
var
     p : pa;
...
     GetMem(p,sizeof(a));

Also tried changing 100M of byte with 25M of cardinal but got the same error.

Operating system is WinXP SP2. AthlonXP 2000+ and 1.25 GBRam

Reply by email

Leonardo M. Ram�
to Eduardo: Hello: I have a little problem, i participe in the 'Large Compression Benchmark'…

I don't tested this with large files, but why don't you use TMemoryStream:

var
  myFile: TMemoryStream;
begin
  myFile := TMemoryStream.Create;
  myFile.LoadFromFile('c:\myfile');
  ...
end;
--- Eduardo wrote 24 lines
Hello: I have a little problem, i participe in the 'Large Compression Benchmark' (http://cs.fit.edu/~mmahoney/compression/text.html) and need to cache the whole enwik8 file (100MB) on memory but when i try to allocate space for it i get a compiler error, saying that maximum is 64MB (67108864). I tried to use $MEMORY 200000000,500000000 (200MB stack and 500MB heap) and the compiler switches, but no success. I need all the file on RAM beacause i want to do a BWT, which implies a sort of the 100MB and uses 400 more MB, and doing so from hard disk is very slow. The contest has a time limit of 10 hours on a 1Ghz machine, but i need all speed at BWT/sort phase, so i can spend the time on getting better compression. Must i touch the system, rtl etc... files and recompile compiler? Or is there another, and simpler, way? P.D. Of course, my pc has more than 100 MB (1.25 GB) _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Leonardo M. Ramé
http://leonardorame.blogspot.com

__________________________________________________ Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

Reply by email

Marco van de Voort
to Eduardo: Oppsss, sorry, I have tried to allocate using pointer, direct array var and pointer to…
>On 11 Sep 2006, at 18:09, Eduardo wrote: Also tried changing 100M of byte with 25M of cardinal but got the same error. Operating system is WinXP SP2. AthlonXP 2000+ and 1.25 GBRam

What are you compiling _for_ ? The plain dos compiler has a limit of 64MB under Windows. Make sure you use the Windows (win32) compiler under windows.

fpc -iTO

will show the target. If it says "go32v2" you have the wrong (dos) compiler.

Reply by email

Пётр Косаревский
var a : array[1..100000000] of byte; //100MB Operating system is WinXP SP2. AthlonXP 2000+ and 1.25 GBRam
Both with 2.1.1 rev. 4609 and 2.0.4rc2:
{$MODE OBJFPC}
var a: array[1..100000000] of byte;
    i: integer;
begin write('('); for i:=1 to 100000000 do a[i]:=a[100000001-i]; writeln(')'); end.

Works allright. (I use "fpc -vlwni -Xs -Xi -Sg -O3rp4" by default.) WinXP-sp2, Celeron 2.4 GHz.

Reply by email

Eduardo
to Пётр Косаревский
you wrote 14 lines
> var > a : array[1..100000000] of byte; //100MB > Operating system is WinXP SP2. AthlonXP 2000+ and 1.25 GBRam Both with 2.1.1 rev. 4609 and 2.0.4rc2: {$MODE OBJFPC} var a: array[1..100000000] of byte; i: integer; begin write('('); for i:=1 to 100000000 do a[i]:=a[100000001-i]; writeln(')'); end. Works allright. (I use "fpc -vlwni -Xs -Xi -Sg -O3rp4" by default.) WinXP-sp2, Celeron 2.4 GHz.

Yes, after make a clean directory and copy there *.pas files, now works, don't know what happened.

Sorry for your time, and thanks Jonas and Ppkk

Reply by email

Eduardo
to Leonardo M. Ram�: I don't tested this with large files, but why don't you use TMemoryStream: var myFile:…
you wrote 10 lines
I don't tested this with large files, but why don't you use TMemoryStream: var myFile: TMemoryStream; begin myFile := TMemoryStream.Create; myFile.LoadFromFile('c:\myfile'); ... end;

Not need OOP for do it, i need as much speed as i can and using a plain array is faster than a stream. Also, now all compiles, perhaps for a temp files cleaning or the dos<->win32 (i don't use "windows" in uses clause, or my ide have dos as default) as Marco said.

Thanks again to all.

Reply by email