Fall back to ps in the profiler.
If the /proc filesystem doesn't exist we'll fall back to using the `ps` shell command.
This commit is contained in:
		
							parent
							
								
									1b58723e7d
								
							
						
					
					
						commit
						043ea9a366
					
				|  | @ -5,13 +5,19 @@ require_relative '../lib/oga' | ||||||
| Thread.abort_on_exception = true | Thread.abort_on_exception = true | ||||||
| 
 | 
 | ||||||
| ## | ## | ||||||
| # Returns memory usage in bytes. This relies on the /proc filesystem, it won't | # Returns memory usage in bytes. If /proc exists it is used, otherwise it falls | ||||||
| # work without it. | # back to `ps`. | ||||||
| # | # | ||||||
| # @return [Fixnum] | # @return [Fixnum] | ||||||
| # | # | ||||||
| def memory_usage | def memory_usage | ||||||
|   return File.read('/proc/self/status').match(/VmRSS:\s+(\d+)/)[1].to_i * 1024 |   if File.exists?('/proc') | ||||||
|  |     kb = File.read('/proc/self/status').match(/VmRSS:\s+(\d+)/)[1].to_i | ||||||
|  |   else | ||||||
|  |     kb = `ps -o rss= #{Process.pid}`.strip.to_i | ||||||
|  |   end | ||||||
|  | 
 | ||||||
|  |   return kb * 1024 | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| ## | ## | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue