Merge pull request #7853 from edx/hotfix/2015-04-29
do garbage collection when dumping memory
This commit is contained in:
@@ -79,7 +79,7 @@ function() {
|
||||
var captions = getCaptions();
|
||||
|
||||
if (startTimes.length !== captions.length) {
|
||||
throw new Exception("video caption and start time arrays do not match in length");
|
||||
console.warn("video caption and start time arrays do not match in length");
|
||||
}
|
||||
|
||||
// if end is null, then it's been set to
|
||||
|
||||
@@ -1,14 +1,33 @@
|
||||
import os
|
||||
import signal
|
||||
import tempfile
|
||||
import gc
|
||||
|
||||
from datetime import datetime
|
||||
from meliae import scanner
|
||||
|
||||
|
||||
def dump_memory(signum, frame):
|
||||
"""Dump memory stats for the current process to a temp directory. Uses the meliae output format."""
|
||||
scanner.dump_all_objects('{}/meliae.{}.{}.dump'.format(tempfile.gettempdir(), datetime.now().isoformat(), os.getpid()))
|
||||
"""
|
||||
Dump memory stats for the current process to a temp directory.
|
||||
Uses the meliae output format.
|
||||
"""
|
||||
|
||||
timestamp = datetime.now().isoformat()
|
||||
format_str = '{}/meliae.{}.{}.{{}}.dump'.format(
|
||||
tempfile.gettempdir(),
|
||||
timestamp,
|
||||
os.getpid(),
|
||||
)
|
||||
|
||||
scanner.dump_all_objects(format_str.format('pre-gc'))
|
||||
|
||||
# force garbarge collection
|
||||
for gen in xrange(3):
|
||||
gc.collect(gen)
|
||||
scanner.dump_all_objects(
|
||||
format_str.format("gc-gen-{}".format(gen))
|
||||
)
|
||||
|
||||
|
||||
def install_memory_dumper(dump_signal=signal.SIGPROF):
|
||||
|
||||
Reference in New Issue
Block a user