[sr-dev] A script function to get the reamining PKG MEM

Andrei Pelinescu-Onciul andrei at iptel.org
Mon Apr 19 09:57:54 CEST 2010


On Apr 16, 2010 at 13:58, I??aki Baz Castillo <ibc at aliax.net> wrote:
> 2010/4/16 Henning Westerholt <henning.westerholt at 1und1.de>:
> > Hello Inaki,
> >
> > transaction live mainly in shared memory, so this could be another reason that
> > the t_relay/ t_newtran fails
> 
> Yes sorry, my fault. Basically the problem would be the fact that the
> worker has not enough memory to parse and create an error response.
> 
> 
> >. But you're right, it should also fail due
> > insufficient private memory .
> >
> >> So what I'm in mind is a new script function to get the current
> >> available PKG mem, so the script can determine not to process the
> >> request and reply (if it can) an error response. This would avoid the
> >> creation of a new dialog, db queries and so on.
> >
> > There are already some functions that output mem status, albeit in the log.
> > Take a look to pkg_status/shm_status() in cfgutils. So one could of course
> > implement a PV that returns the number of available memory, or a function that
> > checks for a certain range.
> 
> Thanks.


Try pkg_available() or shm_available().
Note however that this information is not always available
(depends on the compilations options). When not available, they will
always return max. ulong ( (unsigned long)-1).

You might want to look also at pkg_info(&mi) and shm_info(&mi). They
fill a struct mem_info (defined in mem/meminfo.h):

struct mem_info{
    unsigned long total_size;
    unsigned long free;
    unsigned long used;
    unsigned long real_used; /*used + overhead*/
    unsigned long max_used;
    unsigned long min_frag;
    unsigned long total_frags; /* total fragment no */
};

[...]

Andrei



More information about the sr-dev mailing list