From e1683b8e1c2b894f59c7643050aecd149e864a61 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 4 Aug 2015 11:26:51 +0100 Subject: [PATCH] added a /gc endpoint to debug filestore memory usage --- services/filestore/app.coffee | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/services/filestore/app.coffee b/services/filestore/app.coffee index 9c744e75ab..c06353518b 100644 --- a/services/filestore/app.coffee +++ b/services/filestore/app.coffee @@ -85,6 +85,17 @@ app.post "/project/:project_id/public/:public_file_id", keyBuilder.publicFileKey app.put "/project/:project_id/public/:public_file_id", keyBuilder.publicFileKey, fileController.copyFile app.del "/project/:project_id/public/:public_file_id", keyBuilder.publicFileKey, fileController.deleteFile +app.get "/gc", (req, res)-> + if global.gc? + memory_before = process.memoryUsage() + global.gc() + memory_after = process.memoryUsage() + delta = {} + for k of memory_after + delta[k] = memory_after[k] - memory_before[k] + res.send { memory_before, memory_after, delta } + else + res.send(501) # need --expose-gc, send "not implemented" app.get "/heapdump", (req, res)-> require('heapdump').writeSnapshot '/tmp/' + Date.now() + '.filestore.heapsnapshot', (err, filename)->