Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
fix(memory_leak): try to fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
felix committed Sep 24, 2019
1 parent fede29c commit 7108460
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions gnes/preprocessor/io_utils/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ def encode_video(images: 'np.ndarray',
err = '\n'.join([' '.join(cmd_args), err.decode('utf8')])
raise IOError(err)

if proc.stdout is not None:
proc.stdout.close()
if proc.stderr is not None:
proc.stderr.close()

return output


Expand Down
4 changes: 2 additions & 2 deletions gnes/preprocessor/video/shotdetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def detect_shots(self, frames: 'np.ndarray') -> List[List['np.ndarray']]:

shots = []
for ci in range(0, len(shot_bounds) - 1):
shots.append(frames[shot_bounds[ci]:shot_bounds[ci + 1]])
shots.append(frames[shot_bounds[ci]:shot_bounds[ci + 1]].copy())

return shots

Expand All @@ -87,7 +87,7 @@ def apply(self, doc: 'gnes_pb2.Document') -> None:
elif raw_type == gnes_pb2.NdArray:
video_frames = blob2array(doc.raw_video)
if self.vframes > 0:
video_frames = video_frames[0:self.vframes, :]
video_frames = video_frames[0:self.vframes, :].copy()

num_frames = len(video_frames)
if num_frames > 0:
Expand Down

0 comments on commit 7108460

Please sign in to comment.