|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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. ![]() |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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'. |
|
![]() |
| Outils de la discussion | |
|
|