Thread: Re: BUG #3680: memory leak when excuting a SQL "selectcount(id) from chinatelecom;"

Thank you for the explanations.
My program is running 4 months, it has never exit because of the shortage of
memory. But the 'free' memory (observing by top command) is kept on about
20MB (The database server has 2GB DDR RAM).

According to you explanations, when I "malloc" a buffer of 30MB, the cache
will be reduced to give me 30MB. I think it is true. So another question is
whether the efficiency of program is affected to go down?
                                                   ssurui@mailst.xjtu.edu.cn




----------------------------------------------------------------------------
------------------------------------------------------------------
I think the one thing everyone knows as a fact is that the memory did not
vanish.  Your latest message gives us a clue that what interests you is why
free (unused, idle, not giving you any benefit) memory went down.  If that
is the question, it is because PostgreSQL goes through the OS file systems,
so RAM which is serving no other purpose will automatically be used to cache
data.  If you need memory for something else, the cache will be reduced to
compensate.

-Kevin

Re: BUG #3680: memory leak when excuting a SQL "selectcount(id) from chinatelecom;"

From
Douglas Toltzman
Date:
Actually, the reason for utilizing all available RAM is to improve=20=20
efficiency.  There is no cost to leaving things in core, in case they=20=20
will can be re-used.  It takes virtually no time to make pages=20=20
available when they are needed.  The only cost is in managing=20=20
utilization maps, but accessing the hard drive takes milliseconds=20=20
where getting something from RAM takes nanoseconds.  It's really an=20=20
operating system thing, not a Postgres issue.

On Oct 17, 2007, at 9:04 PM, ssurui wrote:

> Thank you for the explanations.
>
> My program is running 4 months, it has never exit because of the=20=20
> shortage of memory. But the =91free=92 memory (observing by top=20=20
> command) is kept on about 20MB (The database server has 2GB DDR RAM).
>
>
>
> According to you explanations, when I =93malloc=94 a buffer of 30MB,=20=
=20
> the cache will be reduced to give me 30MB. I think it is true. So=20=20
> another question is whether the efficiency of program is affected=20=20
> to go down?
>
>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20
> ssurui@mailst.xjtu.edu.cn
>
>
>
> ----------------------------------------------------------------------=20
> ----------------------------------------------------------------------=20
> --
>
> I think the one thing everyone knows as a fact is that the memory=20=20
> did not vanish.  Your latest message gives us a clue that what=20=20
> interests you is why free (unused, idle, not giving you any=20=20
> benefit) memory went down.  If that is the question, it is because=20=20
> PostgreSQL goes through the OS file systems, so RAM which is=20=20
> serving no other purpose will automatically be used to cache data.=20=20=
=20
> If you need memory for something else, the cache will be reduced to=20=20
> compensate.
>
>
>
> -Kevin
>
>
Douglas Toltzman
doug@oakstreetsoftware.com
(910) 526-5938