Skip to Main Content
  • Questions
  • How do we calculate memory usage per process ?

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Krishna.

Asked: May 24, 2002 - 12:05 pm UTC

Last updated: January 30, 2005 - 6:33 pm UTC

Version: 8.1.6.3

Viewed 10K+ times! This question is

You Asked

Hi Tom,

We are using Oracle 8.1.6 on Sun Solaris and trying to calculate the RAM size for 500 concurrent users. As per our calculation we are getting 3-5MB per process and one of my friend calims that, we need 30MB per process. I used the following query to calculate the average value per process.

SELECT name, AVG(value)
FROM v$session se, v$sesstat ss, v$statname sn
WHERE ss.sid=se.sid
AND sn.statistic# = ss.statistic#
AND sn.name = 'session pga memory'
AND username = 'ABE'
GROUP BY name;

could you please give me the average value per process.

Thanks a lot,
Krish.

and Tom said...

you did it right -- don't know (cannot IMAGINE) where your friend got "30mb" from?

with 500 concurrent users, you could also look at using MTS (shared server). Turn on shared server and then look at the UGA memory (to help you size the large_pool in the SGA). You need only enough PGA's for the shared servers (of which you might only have 50 or so).




Rating

  (8 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Thanks a lot for the quick reply Tom !

Krishna, May 24, 2002 - 8:37 pm UTC


Reader

A reader, June 03, 2002 - 4:20 pm UTC

Tom,

I recently was reading a BUG report 895995
In the report it was recommended, that Whatever highest value is 
reached (pool heap session (MTS)), set the LARGE_POOL_SIZE to 3x's that size

On my system
SQL>select sum(value) from v$sesstat wher staistic# = 15 -- "session uga memory"
29524368 = ~29 M
SQL>select * from v$sgastat;
....
large pool session heap 26382240 = ~ 25M

Setting the large pool to 3 x 25 = 75 M. , is this a good guide line or that recommendation
is specific to that environment . Why sum(session uga memory) show higher value
than "large pool session heap"

Thanks

 

Tom Kyte
June 03, 2002 - 5:38 pm UTC

They were trying to find the right size -- they were getting 4031's (out of memory). Their first stab was "triple the size and set the large pool to that"

If you aren't hitting errors, I wouldn't change it.

Dedicated servers allocate their UGA out of the PGA (backend processes and such). You needn't count them.


Total memory used by processes..

atul, January 01, 2003 - 12:29 am UTC

Sir,

I am calculating total memory used by all logged in user..
I have 1GB ram..

I'm doing this by,

select decode(NAME,'session pga memory','session pga memory','f') ,sum(VALUE) from
    v$session se, v$sesstat ss, v$statname sn
    WHERE ss.sid=se.sid
        AND sn.statistic# = ss.statistic#
   group by decode(NAME,'session pga memory','session pga memory','f')
SQL> /

DECODE(NAME,'SESSI SUM(VALUE)
------------------ ----------
f                  1312030183
session pga memory   41989456

So,is this correct ??

Thanks.
atul
 

Tom Kyte
January 01, 2003 - 8:29 am UTC

depends. first I don't know the value of "f" -- it is rather meaningless.

there is pga memory and uga memory. in dedicated server mode, uga memory is session memory stored in the pga. in shared server mode, uga memory is session memory stored in the sga. so, depends on how your users connect.

Is the Result in Bytes

Sunil Gururaj, January 02, 2003 - 2:44 am UTC

Hi Tom,

I would like to know if the result of the above query to calculate average value per process in bytes?

Thanks,


Tom Kyte
January 02, 2003 - 7:34 am UTC

yes, it is in bytes.

sessions memory

A Reader, June 15, 2004 - 9:42 am UTC

Dear Tom:

Suppose there are 50 sessions in the Oracle 9i (9201). Now how can we calculate the total RAM which is bieng used by the single Oracle 9i instance, which contains the 50 sessions. Please explain.

Thanks

Tom Kyte
June 15, 2004 - 3:50 pm UTC

add up v$sgastat and the pga values from v$sesstat:

ops$tkyte@ORA10G> l
  1  select a.name, b.value
  2  from v$statname a, v$mystat b
  3  where a.statistic# = b.statistic#
  4* and lower(a.name) like '%' || lower('&S')||'%'
ops$tkyte@ORA10G> /
old   4: and lower(a.name) like '%' || lower('&S')||'%'
new   4: and lower(a.name) like '%' || lower('session pga memory')||'%'
 
NAME                                VALUE
------------------------------ ----------
session pga memory                1022540


 

Total Shared Memory

Goh Seong Hin, July 05, 2004 - 5:12 am UTC

Dear Tom,

    Would like to check with you on the following calculation.

why the total shared_pool in init.ora is different from total sum(bytes) from v$sesstat where pool = 'shared pool'

    show parameter shared
    shared_pool_size                     string  500000000  
<>
  1  select sum(bytes) from v$sgastat
  2* where pool = 'shared pool'
SQL> /
SUM(BYTES)
----------
 525391776      

and Q2. why the total sum(bytes) from v$sesstat <> shared_pool_size - shared pool free memory.

     Thanks in advance.

Rgds
SHGoh 

Memory usage per process

A reader, January 29, 2005 - 10:22 pm UTC

Hi Tom,

If I run the following query :

SELECT name,value/1024/1024
FROM v$session se, v$sesstat ss, v$statname sn
WHERE ss.sid=se.sid
AND sn.statistic# = ss.statistic#
AND sn.name = 'session pga memory'
and se.sid=&vsid;

Do you know which unix command on Aix will show me the amount of memory assign to a specific spid (where the spid is associated with the vsid given as an input parameter in the query )?
I need to demostrate that the amount of memory that the query is showing for a particular session id match the amount of memory that unix will show for that same session.

Thanks for any help you can give on this matter.



Tom Kyte
January 30, 2005 - 9:25 am UTC

it won't though, the OS tools -- unless you use one that breaks out all of the bits and bytes -- over report memory, they show shared memory as well as private memory.

You'll not have much luck reconciling these numbers.

On solaris, you can use pmap to see how detailed this can get. But top, glance, etc -- they way over report (and I don't work on aix so I don't know if aix can or cannot report this level of detail and even if it can, it'll never be exactly the same -- we are simply reporting the malloc()'s we've done)

Memory usage per process

A reader, January 30, 2005 - 6:03 pm UTC

Thanks for answering me Tom.

You said "...I don't know if aix can or cannot report this level of detail and even if it can, it'll never be exactly the same -- we are simply reporting the malloc()'s we've done)"

So does this mean that an oracle process will actually use more memory than the amount that is shown in v$sesstat for the event 'session pga memory'?, If it is so, how can I do in order to calculate the exact amount of memory than an oracle process will be using at any moment?

Thanks for your help on this.

Tom Kyte
January 30, 2005 - 6:33 pm UTC

You cannot "be exact", you will be more than close enough.