Re: show total memory used / allocated by a program

2017-03-18 Thread Otto Moerbeek
On Sat, Mar 18, 2017 at 07:15:29PM +0100, David Lowe wrote:

> On 2017-03-18 09:28, Otto Moerbeek wrote:
> > On Fri, Mar 17, 2017 at 01:04:29PM +0200, Mihai Popescu wrote:
> > 
> > > Hello,
> > > 
> > > I am using top to show running programs activity on an OpenBSD system.
> > > 
> > > Is there another better command to show in detail the memory used by
> > > programs?
> > > 
> > > My system has 8GB physical RAM. Looking at this, can someone tell me
> > > if OpenBSD uses the "swap memory" model used by other OSes, basically
> > > moving chunks from physical memory to the swap partition when they are
> > > not used?
> > 
> > Pages in physical memory are paged out to swap space, if thery are not
> > actively used *and* there is general shortage of physical memory. If
> > physical memory is not tight, no swapping will occur.
> > 
> > > 
> > > If a program ask for a memory allocation, is this request satisfied
> > > imediately if there is enough physical RAM available or is it done at
> > > the moment the program needs to do read/write on that memory?
> > 
> > Virtual memory is allocated subject to per process ulimits and general
> > platform limitation but not touched on allocation. Only when the
> > virtual pages are referred to they will become backed by physical
> > pages. These pages might be paged out to swap if need be.
> > 
> > > 
> > > Expanding the first question, is there a command to show all these
> > > details, like total memory used, static and dynamic, how much is
> > > physical or swap, etc?
> > 
> > top shows two columns: SIZE and RES. SIZE is the total virtual memory
> > used by a process (executable, stack and data). RES are the total
> > physical pages in use by a process. Both columns can be deceptive
> > since e.g. memory can be shared by multiple processes. There are also
> > things like dynamically loaded libraries that complicate matters.
> > 
> > procmap can show a lot of details about a process, but that's maybe
> > too much for your purpose. It also is disabled in a default setup.
> > 
> > but:
> > 
> > $ ps -axO tsiz,dsiz,ssiz,vsz,rss,maxrss,%mem,lim
> > 
> > Will show you most of the details you're after. See the man page for
> > some explanation.
> > 
> > Note: the SIZE and RES columns from top are called vsz and rss in ps,
> > text is the name fthe executable program code.
> 
> Thanks for the explanation!
> May I ask why I am getting RES > SIZE sometimes?
> 
> Here is one line as example:
>  5411 d.lowe  20   12M   16M sleep/2   kqread5:32  0.00% tmux

My guess would be shared libs,

-Otto



Re: show total memory used / allocated by a program

2017-03-18 Thread David Lowe

On 2017-03-18 09:28, Otto Moerbeek wrote:

On Fri, Mar 17, 2017 at 01:04:29PM +0200, Mihai Popescu wrote:


Hello,

I am using top to show running programs activity on an OpenBSD system.

Is there another better command to show in detail the memory used by 
programs?


My system has 8GB physical RAM. Looking at this, can someone tell me
if OpenBSD uses the "swap memory" model used by other OSes, basically
moving chunks from physical memory to the swap partition when they are
not used?


Pages in physical memory are paged out to swap space, if thery are not
actively used *and* there is general shortage of physical memory. If
physical memory is not tight, no swapping will occur.



If a program ask for a memory allocation, is this request satisfied
imediately if there is enough physical RAM available or is it done at
the moment the program needs to do read/write on that memory?


Virtual memory is allocated subject to per process ulimits and general
platform limitation but not touched on allocation. Only when the
virtual pages are referred to they will become backed by physical
pages. These pages might be paged out to swap if need be.



Expanding the first question, is there a command to show all these
details, like total memory used, static and dynamic, how much is
physical or swap, etc?


top shows two columns: SIZE and RES. SIZE is the total virtual memory
used by a process (executable, stack and data). RES are the total
physical pages in use by a process. Both columns can be deceptive
since e.g. memory can be shared by multiple processes. There are also
things like dynamically loaded libraries that complicate matters.

procmap can show a lot of details about a process, but that's maybe
too much for your purpose. It also is disabled in a default setup.

but:

$ ps -axO tsiz,dsiz,ssiz,vsz,rss,maxrss,%mem,lim

Will show you most of the details you're after. See the man page for
some explanation.

Note: the SIZE and RES columns from top are called vsz and rss in ps,
text is the name fthe executable program code.


Thanks for the explanation!
May I ask why I am getting RES > SIZE sometimes?

Here is one line as example:
 5411 d.lowe  20   12M   16M sleep/2   kqread5:32  0.00% tmux





-Otto




Re: show total memory used / allocated by a program

2017-03-18 Thread Otto Moerbeek
On Sat, Mar 18, 2017 at 09:46:54AM +0200, Panagiotis Atmatzidis wrote:

> > On 18 Mar 2017, at 09:38, Flipchan  wrote:
> >
> > I recommend htop
> 
> +1 for ???htop???  here is a nice explanation of each field:
> https://peteris.rocks/blog/htop/ 

I have some reservations:

- "Explanation of everything you can see in htop/top on Linux" while
some concepts may the same, OpenBSD is not Linux. Fields with the same
name might mean something different.

- htop is pulling in way too many libraries to be trusted. I prefer tools
in base.

-Otto



Re: show total memory used / allocated by a program

2017-03-18 Thread Otto Moerbeek
On Fri, Mar 17, 2017 at 01:04:29PM +0200, Mihai Popescu wrote:

> Hello,
> 
> I am using top to show running programs activity on an OpenBSD system.
> 
> Is there another better command to show in detail the memory used by programs?
> 
> My system has 8GB physical RAM. Looking at this, can someone tell me
> if OpenBSD uses the "swap memory" model used by other OSes, basically
> moving chunks from physical memory to the swap partition when they are
> not used?

Pages in physical memory are paged out to swap space, if thery are not
actively used *and* there is general shortage of physical memory. If
physical memory is not tight, no swapping will occur.

> 
> If a program ask for a memory allocation, is this request satisfied
> imediately if there is enough physical RAM available or is it done at
> the moment the program needs to do read/write on that memory?

Virtual memory is allocated subject to per process ulimits and general
platform limitation but not touched on allocation. Only when the
virtual pages are referred to they will become backed by physical
pages. These pages might be paged out to swap if need be.

> 
> Expanding the first question, is there a command to show all these
> details, like total memory used, static and dynamic, how much is
> physical or swap, etc?

top shows two columns: SIZE and RES. SIZE is the total virtual memory
used by a process (executable, stack and data). RES are the total
physical pages in use by a process. Both columns can be deceptive
since e.g. memory can be shared by multiple processes. There are also
things like dynamically loaded libraries that complicate matters.

procmap can show a lot of details about a process, but that's maybe
too much for your purpose. It also is disabled in a default setup.

but:

$ ps -axO tsiz,dsiz,ssiz,vsz,rss,maxrss,%mem,lim

Will show you most of the details you're after. See the man page for
some explanation.

Note: the SIZE and RES columns from top are called vsz and rss in ps,
text is the name fthe executable program code.

-Otto



Re: show total memory used / allocated by a program

2017-03-18 Thread Panagiotis Atmatzidis
> On 18 Mar 2017, at 09:38, Flipchan  wrote:
>
> I recommend htop

+1 for “htop”  here is a nice explanation of each field:
https://peteris.rocks/blog/htop/ 

--
Panagiotis (atmosx) Atmatzidis

email:  a...@convalesco.org
URL:http://www.convalesco.org
GnuPG ID: 0x1A7BFEC5
gpg --keyserver pgp.mit.edu --recv-keys 1A7BFEC5

"Everyone thinks of changing the world, but no one thinks of changing
himself.” - Leo Tolstoy

[demime 1.01d removed an attachment of type application/pgp-signature which had 
a name of signature.asc]



Re: show total memory used / allocated by a program

2017-03-18 Thread Flipchan
I recommend htop

Mihai Popescu  skrev: (17 mars 2017 12:04:29 CET)
>Hello,
>
>I am using top to show running programs activity on an OpenBSD system.
>
>Is there another better command to show in detail the memory used by
>programs?
>
>My system has 8GB physical RAM. Looking at this, can someone tell me
>if OpenBSD uses the "swap memory" model used by other OSes, basically
>moving chunks from physical memory to the swap partition when they are
>not used?
>
>If a program ask for a memory allocation, is this request satisfied
>imediately if there is enough physical RAM available or is it done at
>the moment the program needs to do read/write on that memory?
>
>Expanding the first question, is there a command to show all these
>details, like total memory used, static and dynamic, how much is
>physical or swap, etc?
>
>Thank you.

--
Sincerly flipchan - LayerProx dev



Re: show total memory used / allocated by a program

2017-03-17 Thread Abel Abraham Camarillo Ojeda
You could also use time(1), the command, not the shell built-in:

$ env time -l echo

0.00 real 0.01 user 0.00 sys
   552  maximum resident set size
 0  average shared memory size
 0  average unshared data size
 0  average unshared stack size
51  minor page faults
15  major page faults
 0  swaps
 4  block input operations
 0  block output operations
 0  messages sent
 0  messages received
 0  signals received
 4  voluntary context switches
 0  involuntary context switches
$



On Fri, Mar 17, 2017 at 10:13 AM, Manuel Solis 
wrote:
> Hello again!!
>
>
> Yes, indeed systat and vmstat are a good options too.
>
> Mihai Popescu,
>
> Please try one of these examples and see if they show you the information
> you are looking for:
>
> suggestion1:  $ top |head -n5| tail -n1
> suggestion2:  $ vmstat -s|more
> suggestion3:  $ vmstat -m|more
> suggestion4:  $ systat
>
> I hope this information will help :)
>
> Manuel
>
>
> On Fri, Mar 17, 2017 at 9:19 AM, Edgar Pettijohn 
> wrote:
>
>> .
>>
>> > On Mar 17, 2017, at 9:21 AM, Manuel Solis 
>> wrote:
>> >
>> > Hello,
>> >
>> >> El 17/03/2017, a las 05:04, Mihai Popescu  escribió:
>> >>
>> >> Hello,
>> >>
>> >> I am using top to show running programs activity on an OpenBSD system.
>> >>
>> >> Is there another better command to show in detail the memory used by
>> > programs?
>> >
>> > Top is really a good command, you should see de man page for more
>> options.
>> >
>> >>
>> >> My system has 8GB physical RAM. Looking at this, can someone tell me
>> >> if OpenBSD uses the "swap memory" model used by other OSes, basically
>> >> moving chunks from physical memory to the swap partition when they are
>> >> not used?
>> >
>> > Yes it does, you could use the #disklabel  command to see it
>> >>
>> >> If a program ask for a memory allocation, is this request satisfied
>> >> imediately if there is enough physical RAM available or is it done at
>> >> the moment the program needs to do read/write on that memory?
>> >>
>> >> Expanding the first question, is there a command to show all these
>> >> details, like total memory used, static and dynamic, how much is
>> >> physical or swap, etc?
>> >>
>> > top is the command that you are looking for :)
>> >
>> >
>> >> Thank you.
>> >>
>> >
>> > I hope that information is useful for your needs, i recommend you to
>> look at
>> > the Faq page
>> > https://www.openbsd.org/faq/index.html
>> > 
>> > they really did a great job explaining everything and most of what it
>> has are
>> > practical examples, if you need expanded theory then you should get the
>> book
>> > Absolute OpenBSD - By Michael W Lucas, it helped me a lot.
>> > http://www.nostarch.com/obenbsd2e 
>> >
>> > Best reggards!!!
>> >
>> > Manuel
>>
>> I think systat or vmstat may be helpful.
>>
>
>
>
> --
> Ing. Manuel Solís Agüero
> Corporativo Los Solises
> Cel: (871) 108 6000
> Tel: (871) 721 6303



Re: show total memory used / allocated by a program

2017-03-17 Thread Manuel Solis
Hello again!!


Yes, indeed systat and vmstat are a good options too.

Mihai Popescu,

Please try one of these examples and see if they show you the information
you are looking for:

suggestion1:  $ top |head -n5| tail -n1
suggestion2:  $ vmstat -s|more
suggestion3:  $ vmstat -m|more
suggestion4:  $ systat

I hope this information will help :)

Manuel


On Fri, Mar 17, 2017 at 9:19 AM, Edgar Pettijohn 
wrote:

> .
>
> > On Mar 17, 2017, at 9:21 AM, Manuel Solis 
> wrote:
> >
> > Hello,
> >
> >> El 17/03/2017, a las 05:04, Mihai Popescu  escribió:
> >>
> >> Hello,
> >>
> >> I am using top to show running programs activity on an OpenBSD system.
> >>
> >> Is there another better command to show in detail the memory used by
> > programs?
> >
> > Top is really a good command, you should see de man page for more
> options.
> >
> >>
> >> My system has 8GB physical RAM. Looking at this, can someone tell me
> >> if OpenBSD uses the "swap memory" model used by other OSes, basically
> >> moving chunks from physical memory to the swap partition when they are
> >> not used?
> >
> > Yes it does, you could use the #disklabel  command to see it
> >>
> >> If a program ask for a memory allocation, is this request satisfied
> >> imediately if there is enough physical RAM available or is it done at
> >> the moment the program needs to do read/write on that memory?
> >>
> >> Expanding the first question, is there a command to show all these
> >> details, like total memory used, static and dynamic, how much is
> >> physical or swap, etc?
> >>
> > top is the command that you are looking for :)
> >
> >
> >> Thank you.
> >>
> >
> > I hope that information is useful for your needs, i recommend you to
> look at
> > the Faq page
> > https://www.openbsd.org/faq/index.html
> > 
> > they really did a great job explaining everything and most of what it
> has are
> > practical examples, if you need expanded theory then you should get the
> book
> > Absolute OpenBSD - By Michael W Lucas, it helped me a lot.
> > http://www.nostarch.com/obenbsd2e 
> >
> > Best reggards!!!
> >
> > Manuel
>
> I think systat or vmstat may be helpful.
>



--
Ing. Manuel Solís Agüero
Corporativo Los Solises
Cel: (871) 108 6000
Tel: (871) 721 6303



Re: show total memory used / allocated by a program

2017-03-17 Thread Edgar Pettijohn
.

> On Mar 17, 2017, at 9:21 AM, Manuel Solis  wrote:
>
> Hello,
>
>> El 17/03/2017, a las 05:04, Mihai Popescu  escribió:
>>
>> Hello,
>>
>> I am using top to show running programs activity on an OpenBSD system.
>>
>> Is there another better command to show in detail the memory used by
> programs?
>
> Top is really a good command, you should see de man page for more options.
>
>>
>> My system has 8GB physical RAM. Looking at this, can someone tell me
>> if OpenBSD uses the "swap memory" model used by other OSes, basically
>> moving chunks from physical memory to the swap partition when they are
>> not used?
>
> Yes it does, you could use the #disklabel  command to see it
>>
>> If a program ask for a memory allocation, is this request satisfied
>> imediately if there is enough physical RAM available or is it done at
>> the moment the program needs to do read/write on that memory?
>>
>> Expanding the first question, is there a command to show all these
>> details, like total memory used, static and dynamic, how much is
>> physical or swap, etc?
>>
> top is the command that you are looking for :)
>
>
>> Thank you.
>>
>
> I hope that information is useful for your needs, i recommend you to look
at
> the Faq page
> https://www.openbsd.org/faq/index.html
> 
> they really did a great job explaining everything and most of what it has
are
> practical examples, if you need expanded theory then you should get the
book
> Absolute OpenBSD - By Michael W Lucas, it helped me a lot.
> http://www.nostarch.com/obenbsd2e 
>
> Best reggards!!!
>
> Manuel

I think systat or vmstat may be helpful.



Re: show total memory used / allocated by a program

2017-03-17 Thread Manuel Solis
Hello,

> El 17/03/2017, a las 05:04, Mihai Popescu  escribió:
>
> Hello,
>
> I am using top to show running programs activity on an OpenBSD system.
>
> Is there another better command to show in detail the memory used by
programs?

Top is really a good command, you should see de man page for more options.

>
> My system has 8GB physical RAM. Looking at this, can someone tell me
> if OpenBSD uses the "swap memory" model used by other OSes, basically
> moving chunks from physical memory to the swap partition when they are
> not used?

Yes it does, you could use the #disklabel  command to see it
>
> If a program ask for a memory allocation, is this request satisfied
> imediately if there is enough physical RAM available or is it done at
> the moment the program needs to do read/write on that memory?
>
> Expanding the first question, is there a command to show all these
> details, like total memory used, static and dynamic, how much is
> physical or swap, etc?
>
top is the command that you are looking for :)


> Thank you.
>

I hope that information is useful for your needs, i recommend you to look at
the Faq page
https://www.openbsd.org/faq/index.html

they really did a great job explaining everything and most of what it has are
practical examples, if you need expanded theory then you should get the book
Absolute OpenBSD - By Michael W Lucas, it helped me a lot.
http://www.nostarch.com/obenbsd2e 

Best reggards!!!

Manuel



show total memory used / allocated by a program

2017-03-17 Thread Mihai Popescu
Hello,

I am using top to show running programs activity on an OpenBSD system.

Is there another better command to show in detail the memory used by programs?

My system has 8GB physical RAM. Looking at this, can someone tell me
if OpenBSD uses the "swap memory" model used by other OSes, basically
moving chunks from physical memory to the swap partition when they are
not used?

If a program ask for a memory allocation, is this request satisfied
imediately if there is enough physical RAM available or is it done at
the moment the program needs to do read/write on that memory?

Expanding the first question, is there a command to show all these
details, like total memory used, static and dynamic, how much is
physical or swap, etc?

Thank you.