diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3e7147f17f985953282b5c196afc9fa48e7a8be3..6de325cc188916f5fdedcd693419fb34ab5b6b3a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,7 @@ if (CUDA_FOUND) set(CUDA_SOURCES ../../openfpm_devices/src/memory/CudaMemory.cu VCluster/cuda/VCluster_semantic_unit_cuda_tests.cu VCluster/cuda/VCluster_unit_tests.cu ) endif() -add_executable(vcluster_test main.cpp VCluster/VCluster.cpp ../../openfpm_devices/src/memory/HeapMemory.cpp ../../openfpm_devices/src/memory/PtrMemory.cpp ../../openfpm_devices/src/Memleak_check.cpp VCluster/VCluster_unit_tests.cpp VCluster/VCluster_semantic_unit_tests.cpp ${CUDA_SOURCES}) +add_executable(vcluster_test main.cpp VCluster/VCluster.cpp ../../openfpm_devices/src/memory/HeapMemory.cpp ../../openfpm_devices/src/memory/PtrMemory.cpp VCluster/VCluster_unit_tests.cpp VCluster/VCluster_semantic_unit_tests.cpp ${CUDA_SOURCES}) if ( CMAKE_COMPILER_IS_GNUCC ) target_compile_options(vcluster_test PRIVATE "-Wno-deprecated-declarations") diff --git a/src/VCluster/VCluster_meta_function.hpp b/src/VCluster/VCluster_meta_function.hpp index 1c64f86c218047aa10c1a14585f11b2406b6cba5..2e5d4131a39d6cc19bb8889bfd1a2cc62652d724 100644 --- a/src/VCluster/VCluster_meta_function.hpp +++ b/src/VCluster/VCluster_meta_function.hpp @@ -262,7 +262,9 @@ struct unpack_selector_with_prp_lin // add the received particles to the vector PtrMemory * ptr1 = new PtrMemory(recv_buf.get(i).getPointer(),recv_buf.get(i).size()); + ptr1->incRef(); + { // create vector representation to a piece of memory already allocated openfpm::vector::type,layout_base,openfpm::grow_policy_identity> v2; @@ -283,7 +285,10 @@ struct unpack_selector_with_prp_lin sz_byte->get(i) = recv_buf.get(i).size(); if (sz != NULL) sz->get(i) = recv_size_new - recv_size_old; + } + ptr1->decRef(); + delete ptr1; return 1; } };