I'm trying to debug my app and figure out why it runs for around 30-60 seconds before crashing from what Im presuming are memory leaks somewhere. I've tried just looking at it through:
#[derive(Default, Debug)]
pub struct AppStats {
pub memory_mb: Option<u64>,
pub virtual_memory_mb: Option<u64>,
pub total_cpu_usage_percentage: Option<f32>
}
let mut app_stats = use_signal(|| AppStats::default());
use_future(move || async move {
let sys = System::new_all() ;
let pid = sysinfo::get_current_pid().unwrap();
let process = sys.process(pid).unwrap();
loop {
*app_stats.write() = AppStats {
memory_mb: Some(process.memory() / (1024 * 1024)),
virtual_memory_mb: Some(process.virtual_memory() / (1024 * 1024)),
total_cpu_usage_percentage: Some(process.cpu_usage())
};
tokio::time::sleep(Duration::from_secs(1)).await;
}
to see if memory starts ballooning, but my app's cpu usage and memory footprint (at least from within it self) don't move but my app still just freezes and crashes?
Any tips?