Commit f740bdbe by Adam

Merge pull request #7853 from edx/hotfix/2015-04-29

do garbage collection when dumping memory
parents 6167b03e 41a66b52
...@@ -79,7 +79,7 @@ function() { ...@@ -79,7 +79,7 @@ function() {
var captions = getCaptions(); var captions = getCaptions();
if (startTimes.length !== captions.length) { 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 // if end is null, then it's been set to
......
import os import os
import signal import signal
import tempfile import tempfile
import gc
from datetime import datetime from datetime import datetime
from meliae import scanner from meliae import scanner
def dump_memory(signum, frame): 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): def install_memory_dumper(dump_signal=signal.SIGPROF):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment