I have created a launcher using GTK4 and Rust.
Here are some previews (including a dictionary and an app launcher), and now it also supports a calculator, clipboard, and window switcher for Hyprland. However, I have a few questions regarding the proper usage of ListView and ListStore.
Since I have multiple plugins, any input sequence would generate results from them and combine them into a new hybrid list. I'm wondering what is the best approach to handle this situation. Currently, I clear the ListStore and add the results to the same ListStore. Should I use a new ListStore to replace the old one?
Do I need to manage memory manually with ListStore or ListView? I made modifications to the ["list_view_apps_launcher"](https://github.com/gtk-rs/gtk4-rs/blame/master/examples/list_view_apps_launcher/main.rs) file as shown in this [pastebin link](https://pastebin.com/63YUceDh).
rust
{
let model = model.clone();
let mut count = 0;
glib::idle_add_local(move || {
if count == 100 {
model.remove_all(); // to remove all items
count = 0;
} else {
gio::AppInfo::all().iter().for_each(|app_info| {
model.append(app_info);
});
count+=1;
}
println!("{} -- {}", count, statm_self().unwrap().resident); // to print the memory use in pages.
ControlFlow::Continue
});
}
Even after clearing the memory each time, I notice that the memory usage continues to increase. How can I avoid this issue?
cargo run --bin list_view_apps_launcher | grep ^0
0 -- 55582
0 -- 58395
0 -- 59014
0 -- 59760
0 -- 60873
0 -- 61923
0 -- 62500
0 -- 64623
0 -- 64197
0 -- 64927
0 -- 64915
0 -- 65899
0 -- 67062
0 -- 66587
0 -- 66587
Thank you in advance.