Sign in Join

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

Mailing lists / fpc-pascal / 2002-05

MaxAvail in Win32 systems

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Lukasz Lesniak

I write a program like database, you know:
Person = record

           name: string[30];
            .......
           phone: string[10];
          end;
  and I am using dynamic list.

When program starts I read all records to memory (BTW: it is good idea?) and I want to check it is enough memory to load next record: if MaxAvail >= SizeOf(Person^.desc) then ...

Please tell me how its work in Win32 because I create file about 400 MB and all record was loaded sucessfully (PC with 64 MB physical RAM and 600 MB virtual memory). I know it's using virtual memory ...

luke BFTH

_________________________________________________________________ Send and receive Hotmail on your mobile device: http://mobile.msn.com

Reply by email

Peter Vreman
to Lukasz Lesniak
Show quoted text 14 lines
I write a program like database, you know: Person = record name: string[30]; ....... phone: string[10]; end; and I am using dynamic list. When program starts I read all records to memory (BTW: it is good idea?) and I want to check it is enough memory to load next record: if MaxAvail >= SizeOf(Person^.desc) then ... Please tell me how its work in Win32 because I create file about 400 MB and all record was loaded sucessfully (PC with 64 MB physical RAM and 600 MB virtual memory). I know it's using virtual memory ...

The Heap will grow when needed. Just check the Heapsize value and you'll see that it increases

Reply by email

Rainer Hantsch
to Lukasz Lesniak: I write a program like database, you know: Person = record name: string[30]; .......…
Lukasz Lesniak wrote 8 lines
I write a program like database, you know: Person = record name: string[30]; ....... phone: string[10]; end; and I am using dynamic list. When program starts I read all records to memory (BTW: it is good idea?)

Well, reading in all data depends on your needs, so the answer (if this is a good idea) is not so easy.
If you write an application which only picks out some data fields from the whole "database" once(!), it makes no sense to read in everything. Here it will be better to read the file sequentially and only add those records to a dynamic list which match your selection.
If you permanently work with the "database", it will be quicker to keep it completely in memory, but this has the disadvantage that... a.) you will loose all changes when your application crashes (or windoze crashes)
b.) you will have to write back the data at least at the end of your application
b.) you cannot change the "database-file" from another task as long as it is not written back from the first task, otherwise you will loose data.

Show quoted text 5 lines
and I want to check it is enough memory to load next record: if MaxAvail >= SizeOf(Person^.desc) then ... Please tell me how its work in Win32 because I create file about 400 MB and all record was loaded sucessfully (PC with 64 MB physical RAM and 600 MB virtual memory). I know it's using virtual memory ...

You should always keep in mind that it will become awfully slow if you exceed the physically available memory (RAM). When Windoze starts swapping, you will get a significant impact in speed, much more as under LINUX! Here it will surely be better to access the records directly on the disk!

Under LINUX, I had a complete WEB shop running for months on a 486DX4/100 with 8MB RAM only for fun and to see if Linux is really so stable... As you can imagine, the system was permanently swapping 24 hours a day (the HDD LED was permanently ON!), but it did not crash and still worked with an acceptable speed. - Great, isn't it?

If you try this with Windoze, be warned, you'll get a blue screen within shortest time... :-)

Have a lot of fun,

Ing. Rainer Hantsch

\\|// Ing. Rainer HANTSCH - Hardware + Software (o o) Forget Windoze! -- We focus on L-I-N-U-X... --oOOo-(_)-oOOo-------------------------------------------------- Ing. Rainer HANTSCH | e-Mail: Khunngasse 21/20 | www : http://www.hantsch.co.at A-1030 Vienna | Tel. : ++43 - 1 - 7988538 0 ---------------------| Fax : ++43 - 1 - 7988538 18 ** AUSTRIA ** | Mobile: ++43 - 664 - 9194382 -----------------------------------------------------------------

Reply by email