Lists: | pgsql-hackers |
---|
From: | Adriano Lange <alange0001(at)gmail(dot)com> |
---|---|
To: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Memory context usage |
Date: | 2009-08-28 02:09:47 |
Message-ID: | 9e2ba6a80908271909n55456c98q4a48f94312454df7@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
How can I get the used memory of a memory context?
Is there some function like:
int getMemoryUsage( MemoryContext )
?
I still working in a subplan cache for a query optimizer and I need to know
whether a temporary memory context is in certain limits.
Thanks
Adriano
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Adriano Lange <alange0001(at)gmail(dot)com> |
Cc: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Memory context usage |
Date: | 2009-08-28 04:46:49 |
Message-ID: | 1740.1251434809@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Adriano Lange <alange0001(at)gmail(dot)com> writes:
> How can I get the used memory of a memory context?
MemoryContextStats() might help. It just dumps the info to stderr
though.
regards, tom lane
From: | Greg Smith <gsmith(at)gregsmith(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Adriano Lange <alange0001(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Memory context usage |
Date: | 2009-08-28 08:18:13 |
Message-ID: | alpine.GSO.2.01.0908280413300.24929@westnet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Fri, 28 Aug 2009, Tom Lane wrote:
> MemoryContextStats() might help. It just dumps the info to stderr
> though.
Which means it ends up in the database log files in the common
configuration where where the database's stderr is redirected to there.
I even script running this regularly against stuff I'm suspicious of,
using something like this passed the PID of the process I want to watch:
#!/bin/bash
gdb -p $1 <<EOF
p MemoryContextStats(TopMemoryContext)
detach
quit
EOF
--
* Greg Smith gsmith(at)gregsmith(dot)com http://www.gregsmith.com Baltimore, MD
From: | Adriano Lange <alange0001(at)gmail(dot)com> |
---|---|
To: | Greg Smith <gsmith(at)gregsmith(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Memory context usage |
Date: | 2009-08-28 11:56:24 |
Message-ID: | 9e2ba6a80908280456m39108dcav35aa073610a5e5aa@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Fri, Aug 28, 2009 at 5:18 AM, Greg Smith<gsmith(at)gregsmith(dot)com> wrote:
> On Fri, 28 Aug 2009, Tom Lane wrote:
>
>> MemoryContextStats() might help. It just dumps the info to stderr
>> though.
>
> Which means it ends up in the database log files in the common configuration
> where where the database's stderr is redirected to there. I even script
> running this regularly against stuff I'm suspicious of, using something like
> this passed the PID of the process I want to watch:
>
> #!/bin/bash
> gdb -p $1 <<EOF
> p MemoryContextStats(TopMemoryContext)
> detach
> quit
> EOF
>
> --
> * Greg Smith gsmith(at)gregsmith(dot)com http://www.gregsmith.com Baltimore, MD
>
Is there another way to get it in the source code?
I need to control the size of a memory context on the fly and take
some actions when
the used memory exceeds a defined size.
Thanks
Adriano
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Adriano Lange <alange0001(at)gmail(dot)com> |
Cc: | Greg Smith <gsmith(at)gregsmith(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Memory context usage |
Date: | 2009-08-28 14:00:46 |
Message-ID: | 7955.1251468046@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Adriano Lange <alange0001(at)gmail(dot)com> writes:
> I need to control the size of a memory context on the fly and take
> some actions when
> the used memory exceeds a defined size.
The existing places that do that sort of thing do their own counting
of how much they've allocated.
regards, tom lane
From: | Adriano Lange <alange0001(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Greg Smith <gsmith(at)gregsmith(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Memory context usage |
Date: | 2009-08-29 19:18:33 |
Message-ID: | 4A997F09.40109@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Tom Lane escreveu:
> Adriano Lange <alange0001(at)gmail(dot)com> writes:
>> I need to control the size of a memory context on the fly and take
>> some actions when
>> the used memory exceeds a defined size.
>
> The existing places that do that sort of thing do their own counting
> of how much they've allocated.
I have seen that the AllocSet structure is hid by MemoryContext which
has only a stderr output interface for its stats. I would need these
stats internally but maybe this is only my demand for now.
Thanks for attention.
Adriano