Re: Total memory allocated to postgres

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: vamsi krishna <vamsikrishna1902(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Total memory allocated to postgres
Date: 2010-10-09 03:16:41
Message-ID: AANLkTimweHoa6c6kDEH4x0R2_PSo6W+5xkEKbAyiCJmc@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Oct 8, 2010 at 10:37 AM, vamsi krishna
<vamsikrishna1902(at)gmail(dot)com> wrote:
> I want to know how much main memory  is actually allocated to be the maximum
> memory for postgresql, because my hardware may have 4GB main memory but at
> the end of the day, only 1GB may be allocated for postgres.
>
> I want to set (increase) it manually. Can someone tell me how to do it?
>
> In aset.c we have a function
> AllocSetContextCreate(MemoryContext parent,const char *name,Size
> minContextSize,Size initBlockSize,Size maxBlockSize) defn.
>
> maxBlockSize is initialized to 8MB in mcxt.c where AllocSetContextCreate()
> is called. If I increase this value to 80 MB or so, will it increase the
> memory allocated to postgresql or will it just increase the block size?

That's not going to work.

> OR
>
> do I need to change some parameter in postgresql.conf file in data directory
> in pgsql folder?

The total amount of memory used by postgresql isn't something that you
can easily control exactly. The two configuration variables that have
the most impact on it are shared_buffers and work_mem. See
http://www.postgresql.org/docs/current/static/runtime-config-resource.html#RUNTIME-CONFIG-RESOURCE-MEMORY

Keep in mind that PostgreSQL relies on the system buffer cache to some
degree. You may need to play around with the parameters a bit to see
what makes your system work best. I wouldn't focus so much on
measuring memory usage as looking at whether everything you have
running on the machine is running well and giving decent performance.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2010-10-09 07:33:20 Re: Sync Replication with transaction-controlled durability
Previous Message Robert Haas 2010-10-09 03:12:42 Re: getting set up on git (finally)