Skip to content

A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.

fix: resolves insufficient memory issue .

towfiqi0c29177923f7
diff --git a/backend/__tests__/managers/handlers/BackupHandler.test.ts b/backend/__tests__/managers/handlers/BackupHandler.test.ts
index 05178a7..41a24ae 100644
--- a/backend/__tests__/managers/handlers/BackupHandler.test.ts
+++ b/backend/__tests__/managers/handlers/BackupHandler.test.ts
@@ -540,8 +540,7 @@ describe('BackupHandler', () => {
const { configService: cs } = require('../../../src/services/ConfigService');
const origKey = cs.config.ENCRYPTION_KEY;
cs.config.ENCRYPTION_KEY = '';
- // The maxProcessor is 2, so required memory is 64MB * 2 = 128MB
- // Provide way more than needed to ensure this check passes
+ // Provide enough memory to pass the memory check (128MB minimum)
jest.spyOn(os, 'freemem').mockReturnValue(1024 * 1024 * 1024); // 1GB
const encryptedOptions = {
diff --git a/backend/src/managers/handlers/BackupHandler.ts b/backend/src/managers/handlers/BackupHandler.ts
index c637536..7dc70ea 100644
--- a/backend/src/managers/handlers/BackupHandler.ts
+++ b/backend/src/managers/handlers/BackupHandler.ts
@@ -437,11 +437,12 @@ export class BackupHandler {
*/
async canRun(options: Record<string, any>, resticArgsAndEnv: ResticArgsAndEnv): Promise<boolean> {
// Check system resource availability
+ // Use a fixed minimum (128MB) rather than scaling by CPU count.
+ // Restic's memory usage doesn't scale linearly with cores, and on macOS
+ // os.freemem() excludes reclaimable cached memory, making it appear
+ // much lower than actually available memory.
const availableMemory = os.freemem();
- const processorCount = resticArgsAndEnv?.resticEnv?.GOMAXPROCS
- ? parseInt(resticArgsAndEnv.resticEnv.GOMAXPROCS, 10)
- : os.cpus().length;
- const requiredMemory = 64 * 1024 * 1024 * processorCount;
+ const requiredMemory = 128 * 1024 * 1024; // 128MB minimum
if (availableMemory < requiredMemory) {
throw new Error(`Insufficient memory to perform backup.`);
}