screencopy: Fix reference cycle, that leaks buffer
Before this, `/proc/$(pidof cosmic-comp)/maps` quickly expands in length when cosmic-workspaces is opened and closed a bunch of time, preventing the GPU memory from being freed. Which on my Intel system can lead to OOM eventually. There may be other leaks to deal with, but `maps` no longer shows this issue.
This commit is contained in:
parent
90227471bf
commit
3697494146
1 changed files with 7 additions and 3 deletions
|
|
@ -23,6 +23,7 @@ use smithay::{reexports::wayland_server::protocol::wl_buffer::WlBuffer, utils::P
|
||||||
use smithay::{
|
use smithay::{
|
||||||
reexports::wayland_server::{
|
reexports::wayland_server::{
|
||||||
protocol::wl_shm, Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource,
|
protocol::wl_shm, Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource,
|
||||||
|
Weak,
|
||||||
},
|
},
|
||||||
utils::Rectangle,
|
utils::Rectangle,
|
||||||
};
|
};
|
||||||
|
|
@ -418,7 +419,9 @@ struct FrameInner {
|
||||||
constraints: Option<BufferConstraints>,
|
constraints: Option<BufferConstraints>,
|
||||||
buffer: Option<WlBuffer>,
|
buffer: Option<WlBuffer>,
|
||||||
damage: Vec<Rectangle<i32, BufferCoords>>,
|
damage: Vec<Rectangle<i32, BufferCoords>>,
|
||||||
obj: ZcosmicScreencopySessionV2,
|
// `SessionInner` contains a `Vec<Frame>`, so use a weak reference here to
|
||||||
|
// avoid a cycle.
|
||||||
|
obj: Weak<ZcosmicScreencopySessionV2>,
|
||||||
capture_requested: bool,
|
capture_requested: bool,
|
||||||
failed: Option<FailureReason>,
|
failed: Option<FailureReason>,
|
||||||
}
|
}
|
||||||
|
|
@ -432,7 +435,7 @@ impl FrameInner {
|
||||||
constraints: constraints.into(),
|
constraints: constraints.into(),
|
||||||
buffer: None,
|
buffer: None,
|
||||||
damage: Vec::new(),
|
damage: Vec::new(),
|
||||||
obj,
|
obj: obj.downgrade(),
|
||||||
capture_requested: false,
|
capture_requested: false,
|
||||||
failed: None,
|
failed: None,
|
||||||
}
|
}
|
||||||
|
|
@ -1019,7 +1022,8 @@ where
|
||||||
.known_cursor_sessions
|
.known_cursor_sessions
|
||||||
.iter()
|
.iter()
|
||||||
.find(|session| {
|
.find(|session| {
|
||||||
session.inner.lock().unwrap().session.as_ref() == Some(&inner.obj)
|
session.inner.lock().unwrap().session.as_ref()
|
||||||
|
== inner.obj.upgrade().ok().as_ref()
|
||||||
})
|
})
|
||||||
.map(|s| CursorSession {
|
.map(|s| CursorSession {
|
||||||
obj: s.obj.clone(),
|
obj: s.obj.clone(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue