PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Function to Display Ruby Memory Usage
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Function to Display Ruby Memory Usage

Réponse
 
LinkBack Outils de la discussion
Vieux 07/01/2008, 01h32   #1
Michael W. Ryder
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Function to Display Ruby Memory Usage

In Business Basic there is a function, DSZ, that shows the current
amount of memory used by the program code and data. This was obviously
more useful in the past where each user might have only 16 KB of memory
available. I was wondering if Ruby had something similar while thinking
about a program. The brute force method could easily take many GB of
memory to solve the problem, while a better algorithm might take a few KB.
Something like this may be useful if developing a program to run on both
a modern PC and something like a cell phone. One could see if they are
using too much memory or if it increases as the problem gets bigger.
  Réponse avec citation
Vieux 07/01/2008, 04h06   #2
M. Edward (Ed) Borasky
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Function to Display Ruby Memory Usage

Michael W. Ryder wrote:
> In Business Basic there is a function, DSZ, that shows the current
> amount of memory used by the program code and data. This was obviously
> more useful in the past where each user might have only 16 KB of memory
> available. I was wondering if Ruby had something similar while thinking
> about a program. The brute force method could easily take many GB of
> memory to solve the problem, while a better algorithm might take a few KB.
> Something like this may be useful if developing a program to run on both
> a modern PC and something like a cell phone. One could see if they are
> using too much memory or if it increases as the problem gets bigger.


I don't know how to do this on Windows, MacOX or BSD, but on Linux, you
can pick up your PID using a call to Process.pid. Then you can shell out
to "pmap" and parse the result, which tells you all the segments and
whether they are mapped to shared libraries or inside the Ruby
executable. The code would look something like this:

pid = Process.pid
map = `pmap -d #{pid}`

# code to parse and analyze the map goes here

See

http://www.linuxdevcenter.com/pub/a/...of-memory.html
http://virtualthreads.blogspot.com/2...-on-linux.html

While you're at it, you could do the same for the PIDs of your web
server and database in Rails.


  Réponse avec citation
Vieux 07/01/2008, 14h58   #3
Jano Svitok
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Function to Display Ruby Memory Usage

On Jan 7, 2008 5:06 AM, M. Edward (Ed) Borasky <znmeb@cesmail.net> wrote:
>
> Michael W. Ryder wrote:
> > ...

> I don't know how to do this on Windows, MacOX or BSD, but on Linux, you
> can pick up your PID using a call to Process.pid. Then you can shell out
> to "pmap" and parse the result, which tells you all the segments and
> whether they are mapped to shared libraries or inside the Ruby
> executable. The code would look something like this:
>
> pid = Process.pid
> map = `pmap -d #{pid}`
>


You'll find (much simpler) version for windows in the archive in
thread 'The real difference between Mutex and Sync'. Search for
'pslist'.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h47.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08447 seconds with 11 queries