Debugging instrumentation
commiting to keep them in history
This commit is contained in:
@@ -69,6 +69,19 @@ export const allowWindowClose = (): void => {
|
||||
* We call this at the end of this file.
|
||||
*/
|
||||
const main = () => {
|
||||
// Debugging memory consumption
|
||||
app.commandLine.appendSwitch("js-flags", "--trace_gc --trace_gc_verbose");
|
||||
app.commandLine.appendSwitch("enable-logging");
|
||||
app.commandLine.appendSwitch("log-file", "chromium.log");
|
||||
app.commandLine.appendSwitch("log-level", "4");
|
||||
app.commandLine.appendSwitch("v", "4");
|
||||
setInterval(() => {
|
||||
const { usedHeapSize, heapSizeLimit } = process.getHeapStatistics();
|
||||
const heapUsed = Math.round(usedHeapSize / 1024);
|
||||
const heapLimit = Math.round(heapSizeLimit / 1024);
|
||||
log.info({ heapUsed, heapLimit });
|
||||
}, 100);
|
||||
|
||||
const gotTheLock = app.requestSingleInstanceLock();
|
||||
if (!gotTheLock) {
|
||||
app.quit();
|
||||
|
||||
@@ -918,6 +918,7 @@ const clusterLivePhotos = async (
|
||||
* it in an informed manner).
|
||||
*/
|
||||
const logAboutMemoryPressureIfNeeded = () => {
|
||||
logMem();
|
||||
if (!globalThis.electron) return;
|
||||
// performance.memory is deprecated in general as a Web standard, and is
|
||||
// also not available in the DOM types provided by TypeScript. However, it
|
||||
@@ -932,3 +933,20 @@ const logAboutMemoryPressureIfNeeded = () => {
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// Debugging memory consumption
|
||||
let started = false;
|
||||
const logMem = () => {
|
||||
if (!globalThis.electron) return;
|
||||
if (started) return;
|
||||
started = true;
|
||||
setInterval(() => {
|
||||
const heapUsed = Math.round(
|
||||
(performance as any).memory.usedJSHeapSize / 1024 ** 2,
|
||||
);
|
||||
const heapTotal = Math.round(
|
||||
(performance as any).memory.usedJSHeapSize / 1024 ** 2,
|
||||
);
|
||||
log.info({ heapUsed, heapTotal });
|
||||
}, 100);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user