Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Debugging instrumentation

Manav Rathi6700f912fc5c
diff --git a/desktop/src/main.ts b/desktop/src/main.ts
index 4ebe565bca..9f00213640 100644
--- a/desktop/src/main.ts
+++ b/desktop/src/main.ts
@@ -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();
diff --git a/web/apps/photos/src/services/upload/uploadManager.ts b/web/apps/photos/src/services/upload/uploadManager.ts
index 96ec37c3c3..9f0525f669 100644
--- a/web/apps/photos/src/services/upload/uploadManager.ts
+++ b/web/apps/photos/src/services/upload/uploadManager.ts
@@ -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);
+};