feat: support manual memory cleanup when running in debug mode

This commit is contained in:
dongchengjie
2024-06-26 17:44:42 +08:00
parent 4f1b8094a3
commit c648dc6c99
6 changed files with 43 additions and 17 deletions

View File

@@ -271,3 +271,24 @@ export const getGroupProxyDelays = async (
);
return result as any as Record<string, number>;
};
// Is debug enabled
export const isDebugEnabled = async () => {
try {
const instance = await getAxios();
await instance.get("/debug/pprof");
return true;
} catch {
return false;
}
};
// GC
export const gc = async () => {
try {
const instance = await getAxios();
await instance.put("/debug/gc");
} catch (error) {
console.error(`Error gcing: ${error}`);
}
};