我正在尝试使用本指南中的代码运行 gnome 扩展 https://gjs.guide/extensions/upgrading/legacy-documentation.html#extensionUbuntu 22.04、GNOME 42.9、waylandcontents 扩展...
我正在尝试使用本指南中的代码运行 gnome 扩展 https://gjs.guide/extensions/upgrading/legacy-documentation.html#extension Ubuntu 22.04、GNOME 42.9、wayland
extension.js 的内容(从上面的链接复制):
const St = imports.gi.St;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
const {
gettext: _,
} = ExtensionUtils;
class Extension {
enable() {
// Create a panel button
this._indicator = new PanelMenu.Button(0.0, Me.metadata.name, false);
// Add an icon
const icon = new St.Icon({
icon_name: 'face-laugh-symbolic',
style_class: 'system-status-icon',
});
this._indicator.add_child(icon);
// Add the indicator to the panel
Main.panel.addToStatusArea(Me.metadata.uuid, this._indicator);
// Add a menu item to open the preferences window
this._indicator.menu.addAction(_('Preferences'),
() => ExtensionUtils.openPrefs());
this._count = 0;
}
disable() {
if (this._indicator) {
this._indicator.destroy();
this._indicator = null;
}
}
}
function init() {
ExtensionUtils.initTranslations();
return new Extension();
}
metadata.json的内容:
{
"uuid": "[email protected]",
"name": "Example Extension",
"description": "An example extension",
"shell-version": [ "42.9" ],
"url": "https://gjs.guide/extensions"
}
错误:
我有一个 shell 脚本来监控系统资源使用情况并发送警报。基本上,它依赖于以下命令:ps -u \'$user\' --no-headers -o pmem | awk '{sum += $1} END {print su...
我有一个 shell 脚本来监控系统资源使用情况并发送警报。基本上,它依赖于以下命令:
ps -u "$user" --no-headers -o pmem | awk '{sum += $1} END {print sum}'
在大多数情况下,它运行良好,但最近我注意到了一些问题。
例如,使用干净的重新启动系统运行以最大限度地减少其他进程的影响:
# R
library(data.table)
library(parallel)
set.seed(123)
n_rows <- 1e7
n_cols <- 1000
## memory black hole!!! change it if necessary, however, you need to require a high level of memory usage (about 1/30 to 1/10 of your usable memory) to achieve significant results in the subsequent tests
dt <- data.table(matrix(runif(n_rows * n_cols), nrow = n_rows, ncol = n_cols))
memory_usage <- object.size(dt)
format(memory_usage, units = "auto")
worker_function <- function(data) {
row_sums <- rowSums(data)
## wait about 30s and run shell command to test when process sleep
Sys.sleep(1000)
return(row_sums)
}
n_threads <- 10
results <- mclapply(1:n_threads, function(x) worker_function(dt), mc.cores = n_threads)
通过top检查内存状态
top
我们可以通过 MEM% 列的总和来获取内存使用率百分比,或者通过以下命令:
ps -u "$user" --no-headers -o pmem | awk '{sum += $1} END {print sum}'
# 113.9
在我的系统(1.5 TiB 内存和 2.0 GiB 交换空间)中,您会发现这个值大于 100,但如果您通过 检查内存 free -h
,您会得到:
仅使用 645/1500 Gib,不到 50%