In that case - yes.. if you did specify data structures that are going to hold the data read from the database, and you explicitly allocate memory (say by declaring size of an array, etc.) - then you could save a little on loading time.
However, again it is application-specific to see if such a "hard-coding" is a good practice or not.
These are two different things. Allocating memory by declaring size of an
array is something inside application, specifing initial size for the
application is outside the program. If the initial memory size is large
enough, allocating memory by declaring an array will cause less Win32 memory
allocation and less page swap, and my program will run faster.
> In that case - yes.. if you did specify data structures that are going to hold the data read from the database, and you explicitly allocate memory
(say by declaring size of an array, etc.) - then you could save a little on
loading time.
> However, again it is application-specific to see if such a "hard-coding" is a good practice or not.
Willy Denoyette [MVP] - 25 Jul 2004 19:05 GMT
How that? If you could, (but fortunately you can't) set the initial size to
something larger than the free (RAM) memory, the system would start swapping
at program start.
If the system starts swapping when your application runs, it's an indication
that you are consuming more memory than you have free in RAM. So it will
always swap.
There are only two things you can do in such situation:
- Review your design in order to reduce the working set of your application.
- Add more RAM.
Willy.
> These are two different things. Allocating memory by declaring size of an
> array is something inside application, specifing initial size for the
[quoted text clipped - 11 lines]
>> However, again it is application-specific to see if such a "hard-coding"
> is a good practice or not.
Christopher Wells - 26 Jul 2004 22:03 GMT
> These are two different things. Allocating memory by declaring size of an
> array is something inside application, specifing initial size for the
> application is outside the program. If the initial memory size is large
> enough, allocating memory by declaring an array will cause less Win32 memory
> allocation and less page swap, and my program will run faster.
There's a Win32 API called SetWorkingSet that affects how much swapping will
happen; a program must be priviledged to call this API (it can reduce the
RAM available to other applications).
Lei Jiang - 27 Jul 2004 06:07 GMT
It seems Process.MinWorkSet and Process.MaxWorkSet do the same thing? I will
try it.
Thanks!
> > These are two different things. Allocating memory by declaring size of an
> > array is something inside application, specifing initial size for the
[quoted text clipped - 6 lines]
> happen; a program must be priviledged to call this API (it can reduce the
> RAM available to other applications).