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 danger
Browse files Browse the repository at this point in the history
  • Loading branch information
felix committed Oct 10, 2019
1 parent 16097f3 commit 9b79cdf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions gnes/preprocessor/io_utils/gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def capture_frames(input_fn: str = 'pipe:',
if pix_fmt == 'rgba':
depth = 4

frames = np.frombuffer(out,
np.uint8).reshape([-1, height, width, depth])
frames = np.frombuffer(out, np.uint8).copy()
frames = frames.reshape([-1, height, width, depth])
return frames


Expand Down
4 changes: 2 additions & 2 deletions gnes/preprocessor/io_utils/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ def capture_frames(input_fn: str = 'pipe:',
if pix_fmt == 'rgba':
depth = 4

frames = np.frombuffer(out,
np.uint8).reshape([-1, height, width, depth])
frames = np.frombuffer(out, np.uint8).copy()
frames = frames.reshape([-1, height, width, depth])
return frames


Expand Down
3 changes: 2 additions & 1 deletion gnes/proto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def blob2array(blob: 'gnes_pb2.NdArray') -> np.ndarray:
"""
Convert a blob proto to an array.
"""
return np.frombuffer(blob.data, dtype=blob.dtype).reshape(blob.shape)
x = np.frombuffer(blob.data, dtype=blob.dtype).copy()
return x.reshape(blob.shape)


def array2blob(x: np.ndarray) -> 'gnes_pb2.NdArray':
Expand Down

0 comments on commit 9b79cdf

Please sign in to comment.