pytorch/caffe2/core
Rohith Menon 4e16be9073 [MemLeak] Fix memory leak from releasing unique ptr (#41883)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/41883

Fix memory leak from releasing unique ptr

Test Plan:
Tested serialization with and without the change.

Heap profile without change:
```
Welcome to jeprof!  For help, type 'help'.
(jeprof) top
Total: 7298.4 MB
  4025.2  55.2%  55.2%   4025.2  55.2% c10::alloc_cpu (inline)
  3195.3  43.8%  98.9%   3195.3  43.8% caffe2::SerializeUsingBytesOrInt32
    63.6   0.9%  99.8%     63.6   0.9% __gnu_cxx::new_allocator::allocate (inline)
     5.0   0.1%  99.9%      5.0   0.1% google::protobuf::RepeatedField::Reserve
     2.5   0.0%  99.9%      2.5   0.0% folly::aligned_malloc (inline)
     1.2   0.0%  99.9%      1.2   0.0% caffe2::detail::CopyFromProtoWithCast (inline)
     1.0   0.0%  99.9%      1.0   0.0% __new_exitfn
     1.0   0.0% 100.0%      1.0   0.0% std::_Function_base::_Base_manager::_M_init_functor (inline)
     0.5   0.0% 100.0%      0.5   0.0% folly::HHWheelTimerBase::newTimer (inline)
     0.5   0.0% 100.0%      0.5   0.0% std::__detail::_Hashtable_alloc::_M_allocate_node
```

Heap profile with change:
```
Welcome to jeprof!  For help, type 'help'.
(jeprof) top
Total: 6689.2 MB
  4025.2  60.2%  60.2%   4025.2  60.2% c10::alloc_cpu (inline)
  2560.0  38.3%  98.4%   2560.0  38.3% caffe2::::HugePagesArena::alloc_huge (inline)
    90.9   1.4%  99.8%     90.9   1.4% __gnu_cxx::new_allocator::allocate (inline)
     5.0   0.1%  99.9%      5.0   0.1% google::protobuf::RepeatedField::Reserve
     2.0   0.0%  99.9%      2.0   0.0% prof_backtrace_impl (inline)
     1.0   0.0%  99.9%     20.3   0.3% std::__cxx11::basic_string::_M_construct (inline)
     1.0   0.0%  99.9%      1.0   0.0% std::_Function_base::_Base_manager::_M_init_functor (inline)
     0.5   0.0%  99.9%      0.5   0.0% folly::UnboundedQueue::allocNextSegment (inline)
     0.5   0.0% 100.0%      0.5   0.0% folly::aligned_malloc (inline)
     0.5   0.0% 100.0%      0.5   0.0% __new_exitfn
```

Reviewed By: yinghai

Differential Revision: D22662093

fbshipit-source-id: d0b8ff1ed26c72b14bb02fb1146c51ef11a7e519
2020-07-22 16:54:19 -07:00
..
hip
nomnigraph remediation of S205607 2020-07-17 17:19:47 -07:00
__init__.py remediation of S205607 2020-07-17 17:19:47 -07:00
allocator.cc
allocator.h
asan.h
blob.h
blob_gpu_test.cc
blob_serialization.cc [MemLeak] Fix memory leak from releasing unique ptr (#41883) 2020-07-22 16:54:19 -07:00
blob_serialization.h Fix typos, via a Levenshtein-type corrector (#31523) 2020-01-17 16:03:19 -08:00
blob_serialization_gpu.cc
blob_serializer_base.h
blob_stats.cc
blob_stats.h
blob_test.cc [caffe2] Enable copying for caffe2::Tensor (#36468) 2020-04-13 21:41:52 -07:00
CMakeLists.txt Formatting cmake (to lowercase without space for if/elseif/else/endif) (#35521) 2020-03-27 14:25:17 -07:00
common.cc
common.h fix windows clang attributes (#33959) 2020-03-02 13:20:51 -08:00
common_cudnn.cc
common_cudnn.h Fix signed-unsigned warnings (#34791) 2020-03-19 00:29:56 -07:00
common_gpu.cc RIP CUDA <9.2: circleci, aten, and caffe2 (#36846) 2020-05-18 13:41:05 -07:00
common_gpu.h fix asserts in cuda code (#39047) 2020-05-28 15:51:38 -07:00
common_omp.h
common_test.cc
context.cc
context.h Call RandomNumberSeed() on-demand (#33539) 2020-02-22 01:22:18 -08:00
context_base.cc Remove Tensor.h, TensorMethods.h from src/core. (#27086) 2019-10-06 09:37:50 -07:00
context_base.h Fix is_fundamental template for MSVC (#30959) 2019-12-19 12:10:22 -08:00
context_gpu.cu [caffe2] Fix of initializing ATen's CUDA before using caching allocator (#39759) 2020-06-09 17:25:42 -07:00
context_gpu.h Do not throw from CUDAContext destructor (#34756) 2020-03-18 00:13:18 -07:00
context_gpu_test.cc
context_test.cc
cudnn_wrappers.h
db.cc
db.h
event.cc caffe2/event: allow multiple errors such as when cancelled (#31335) 2019-12-18 13:10:57 -08:00
event.h Back out "Revert D20449887: [dt][caffe2] enable using smart exceptions in async nets" (#36172) 2020-04-13 11:31:52 -07:00
event_cpu.h
event_gpu.cc Add error message if CUDA startup fails (#29670) 2019-11-13 16:48:40 -08:00
event_gpu_test.cc
event_test.cc caffe2/event: allow multiple errors such as when cancelled (#31335) 2019-12-18 13:10:57 -08:00
export_c10_op_to_caffe2.cc
export_c10_op_to_caffe2.h Remove callBoxedWorkaround (#36850) 2020-04-24 23:13:31 -07:00
export_caffe2_op_to_c10.h [c10] Fix the hanlding for Caffe2 ops which return tensor list (#36841) 2020-04-18 13:30:43 -07:00
flags.h
graph.cc
graph.h
graph_test.cc
init.cc
init.h
init_denormals.cc
init_intrinsics_check.cc cleanup warnings 2019-08-12 16:12:30 -07:00
init_omp.cc
init_test.cc
int8_serialization.cc
logging.h
macros.h
macros.h.in Remove duplicated Numa detection code. (#30628) 2020-01-03 08:48:46 -08:00
memonger.cc Fix typos, via a Levenshtein-type corrector (#31523) 2020-01-17 16:03:19 -08:00
memonger.h
module.cc Allow checking for cached module before asserting (#33954) 2020-03-02 15:43:50 -08:00
module.h cleanup warnings 2019-08-12 16:12:30 -07:00
module_test.cc
net.cc
net.h caffe2/core/plan_executor: add cancellation of async nets on error + propagate exceptions via std::exception_ptr for stack traces (#31966) 2020-04-09 14:38:18 -07:00
net_async_base.cc Back out "Revert D20449887: [dt][caffe2] enable using smart exceptions in async nets" (#36172) 2020-04-13 11:31:52 -07:00
net_async_base.h Back out "Revert D20449887: [dt][caffe2] enable using smart exceptions in async nets" (#36172) 2020-04-13 11:31:52 -07:00
net_async_scheduling.cc Back out "Revert D20449887: [dt][caffe2] enable using smart exceptions in async nets" (#36172) 2020-04-13 11:31:52 -07:00
net_async_scheduling.h caffe2/core/plan_executor: add cancellation of async nets on error + propagate exceptions via std::exception_ptr for stack traces (#31966) 2020-04-09 14:38:18 -07:00
net_async_task.cc Fix signed-unsigned warnings (#34791) 2020-03-19 00:29:56 -07:00
net_async_task.h
net_async_task_future.cc Replace c10::guts::stuff with std::stuff (#30915) 2019-12-16 13:57:19 -08:00
net_async_task_future.h
net_async_task_graph.cc Replace c10::guts::stuff with std::stuff (#30915) 2019-12-16 13:57:19 -08:00
net_async_task_graph.h
net_async_tracing.cc Fix typos, via a Levenshtein-type corrector (#31523) 2020-01-17 16:03:19 -08:00
net_async_tracing.h
net_async_tracing_test.cc
net_dag_utils.cc Fix typos (#30606) 2019-12-02 20:17:42 -08:00
net_dag_utils.h
net_dag_utils_test.cc
net_gpu_test.cc
net_parallel.cc Fix signed-unsigned warnings (#34791) 2020-03-19 00:29:56 -07:00
net_parallel.h
net_simple.cc Wait for all op types in SimpleNet (#39493) 2020-06-11 13:00:34 -07:00
net_simple.h
net_simple_refcount.cc Fix signed-unsigned warnings (#34791) 2020-03-19 00:29:56 -07:00
net_simple_refcount.h
net_simple_refcount_test.cc
net_test.cc Back out "Revert D20449887: [dt][caffe2] enable using smart exceptions in async nets" (#36172) 2020-04-13 11:31:52 -07:00
numa.cc
numa.h
observer.h
observer_test.cc Replace c10::guts::stuff with std::stuff (#30915) 2019-12-16 13:57:19 -08:00
operator.cc Move OperatorBase::AddRelatedBlobInfo implementation to .cc file (#40844) 2020-07-01 11:48:15 -07:00
operator.h add null check for c2 tensor conversion (#41096) 2020-07-09 11:44:23 -07:00
operator_gpu_test.cc
operator_gradient.h
operator_schema.cc Move OperatorSchema default inference function implementations to .cc… (#40845) 2020-07-01 11:42:52 -07:00
operator_schema.h Move OperatorSchema default inference function implementations to .cc… (#40845) 2020-07-01 11:42:52 -07:00
operator_schema_test.cc
operator_test.cc Make msg() and msg_with_backtrace() private (#37094) 2020-05-04 11:54:34 -07:00
parallel_net_test.cc [Caffe2] Increase timing threshold to 50 ms on Windows (#37892) 2020-05-05 19:45:36 -07:00
plan_executor.cc caffe2/core/plan_executor: add cancellation of async nets on error + propagate exceptions via std::exception_ptr for stack traces (#31966) 2020-04-09 14:38:18 -07:00
plan_executor.h
plan_executor_test.cc caffe2/core/plan_executor: add cancellation of async nets on error + propagate exceptions via std::exception_ptr for stack traces (#31966) 2020-04-09 14:38:18 -07:00
prof_dag_counters.cc Fix signed-unsigned warnings (#34791) 2020-03-19 00:29:56 -07:00
prof_dag_counters.h Fix signed-unsigned warnings (#34791) 2020-03-19 00:29:56 -07:00
qtensor.cc
qtensor.h
qtensor_serialization.cc
qtensor_serialization.h
scope_guard.h Fix typos, via a Levenshtein-type corrector (#31523) 2020-01-17 16:03:19 -08:00
static_tracepoint.h
static_tracepoint_elfx86.h Fix typos, via a Levenshtein-type corrector (#31523) 2020-01-17 16:03:19 -08:00
stats.cc
stats.h
stats_test.cc
storage.h
tensor.cc Remove datatype from Storage and StorageImpl (#38870) 2020-05-21 15:26:08 -07:00
tensor.h Rename capacity to nbytes in ShareExternalPointer to avoid confusion in future (#41461) 2020-07-15 22:04:18 -07:00
tensor_impl.h Remove Tensor.h, TensorMethods.h from src/core. (#27086) 2019-10-06 09:37:50 -07:00
tensor_int8.cc
tensor_int8.h
test_utils.cc C++ C2/Glow operator unittest 2020-01-17 12:13:34 -08:00
test_utils.h C++ C2/Glow operator unittest 2020-01-17 12:13:34 -08:00
timer.h
timer_test.cc Increase TimerTest tolerance to 20% on Windows (#35818) 2020-04-01 14:29:05 -07:00
transform.cc
transform.h
transform_test.cc fixup unit tests (#34105) 2020-03-03 10:33:21 -08:00
types.cc Add support to serialize qtensor in JIT. (#23356) 2019-07-26 15:52:15 -07:00
types.h move GetDimFromOrderString to caffe2/core/types.h (#25671) 2019-09-05 04:32:04 -07:00
workspace.cc Wait for all op types in SimpleNet (#39493) 2020-06-11 13:00:34 -07:00
workspace.h Fix typos, via a Levenshtein-type corrector (#31523) 2020-01-17 16:03:19 -08:00
workspace_test.cc