mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Start reporting memory usage for Window and all nodes in all DOM trees for frame treese in script tasks.
This commit is contained in:
parent
c2497fcd49
commit
8620fe5995
33 changed files with 317 additions and 107 deletions
|
@ -13,6 +13,7 @@ use dom::window::ScriptHelpers;
|
|||
use script_task::{ScriptChan, ScriptMsg, TimerSource};
|
||||
use horribly_inefficient_timers;
|
||||
|
||||
use util::mem::HeapSizeOf;
|
||||
use util::task::spawn_named;
|
||||
use util::str::DOMString;
|
||||
|
||||
|
@ -29,14 +30,15 @@ use std::hash::{Hash, Hasher};
|
|||
use std::rc::Rc;
|
||||
use std::default::Default;
|
||||
|
||||
#[derive(JSTraceable, PartialEq, Eq, Copy, Clone)]
|
||||
#[derive(JSTraceable, PartialEq, Eq, Copy, Clone, HeapSizeOf)]
|
||||
pub struct TimerId(i32);
|
||||
|
||||
#[derive(JSTraceable)]
|
||||
#[derive(JSTraceable, HeapSizeOf)]
|
||||
#[privatize]
|
||||
struct TimerHandle {
|
||||
handle: TimerId,
|
||||
data: TimerData,
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
control_chan: Option<Sender<TimerControlMsg>>,
|
||||
}
|
||||
|
||||
|
@ -46,6 +48,13 @@ pub enum TimerCallback {
|
|||
FunctionTimerCallback(Rc<Function>)
|
||||
}
|
||||
|
||||
impl HeapSizeOf for TimerCallback {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
// FIXME: Rc<T> isn't HeapSizeOf and we can't ignore it due to #6870 and #6871
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash for TimerId {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
let TimerId(id) = *self;
|
||||
|
@ -65,7 +74,7 @@ impl TimerHandle {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(JSTraceable)]
|
||||
#[derive(JSTraceable, HeapSizeOf)]
|
||||
#[privatize]
|
||||
pub struct TimerManager {
|
||||
active_timers: DOMRefCell<HashMap<TimerId, TimerHandle>>,
|
||||
|
@ -82,7 +91,7 @@ impl Drop for TimerManager {
|
|||
}
|
||||
|
||||
// Enum allowing more descriptive values for the is_interval field
|
||||
#[derive(JSTraceable, PartialEq, Copy, Clone)]
|
||||
#[derive(JSTraceable, PartialEq, Copy, Clone, HeapSizeOf)]
|
||||
pub enum IsInterval {
|
||||
Interval,
|
||||
NonInterval,
|
||||
|
@ -100,7 +109,7 @@ pub enum TimerControlMsg {
|
|||
// (ie. function value to invoke and all arguments to pass
|
||||
// to the function when calling it)
|
||||
// TODO: Handle rooting during fire_timer when movable GC is turned on
|
||||
#[derive(JSTraceable)]
|
||||
#[derive(JSTraceable, HeapSizeOf)]
|
||||
#[privatize]
|
||||
struct TimerData {
|
||||
is_interval: IsInterval,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue