Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Fix potential memory leak (#1167)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanwharris authored Feb 14, 2022
1 parent 3ec0405 commit 381aa37
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions flash/core/data/io/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import functools
import os
import sys
from copy import copy, deepcopy
from copy import deepcopy
from dataclasses import dataclass
from functools import partial
from typing import Any, Callable, cast, Dict, Iterable, List, MutableMapping, Optional, Sequence, Tuple, Type, Union
Expand Down Expand Up @@ -233,7 +233,9 @@ def _call_load_sample(self, sample: Any) -> Any:
InputBase,
),
)
return load_sample(copy(sample))

# Deepcopy the sample to avoid leaks with complex data structures
return load_sample(deepcopy(sample))

@staticmethod
def load_data(*args: Any, **kwargs: Any) -> Union[Sequence, Iterable]:
Expand Down

0 comments on commit 381aa37

Please sign in to comment.