➕ linux-only memory measurement
							parent
							
								
									70eb419fdc
								
							
						
					
					
						commit
						7fe4444b65
					
				| 
						 | 
				
			
			@ -249,6 +249,20 @@ pub async fn handle (
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn get_rss_from_status (proc_status: &str) -> Option <u64>
 | 
			
		||||
{
 | 
			
		||||
	use std::str::FromStr;
 | 
			
		||||
	
 | 
			
		||||
	for line in proc_status.lines () {
 | 
			
		||||
		if let Some (rest) = line.strip_prefix ("VmRSS:\t").and_then (|s| s.strip_suffix (" kB")) 
 | 
			
		||||
		{
 | 
			
		||||
			return u64::from_str (rest.trim_start ()).ok ();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	None
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[cfg (test)]
 | 
			
		||||
mod tests {
 | 
			
		||||
	use std::{
 | 
			
		||||
| 
						 | 
				
			
			@ -425,4 +439,11 @@ mod tests {
 | 
			
		|||
			
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	#[test]
 | 
			
		||||
	fn rss () {
 | 
			
		||||
		let input = "VmHWM:	584 kB\nVmRSS:	  584 kB\nRssAnon:	  68 kB\n";
 | 
			
		||||
		
 | 
			
		||||
		assert_eq! (get_rss_from_status (input), Some (584));
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue