You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if before call set_cpu_data(set_gpu_data), the head_ = SYNCED which means both gpu memory and cpu memory has mallced, so after call set_cpu_data(set_gpu_data), from the definition we could see the original mallced cpu(gpu) memory is set free, and assign a new data point, but the original gpu(cpu) memory has not be free, is this will cause memory leak?
in addition, l set_cpu_data(set_gpu_data) just transmit the pointer, we don't know the new memory block size, is this a problem?
The text was updated successfully, but these errors were encountered:
I think set_cpu_data just means set the host(cpu side) memory, It has no need to deal with the device(gpu side) memory. The device memory will not be wasted because to_gpu(defined in syncedmem.cpp) can memcopy the data from cpu_ptr_ to gpu_ptr_.
Noiredd
changed the title
SyncedMemory::set_cpu_data and set_gpu_data
SyncedMemory::set_cpu_data and set_gpu_data
Feb 5, 2018
There will be no memory leak - SyncedMemory frees its pointers upon its own destruction. When you feed it a new pointer (to memory you allocated manually), it takes ownership of it - it makes no difference whether the memory has been allocated by the object itself or by you. But when you replace a pointer with your own (set_&pu_data), it has to free the existing memory to avoid the leak.
if before call
set_cpu_data
(set_gpu_data
), the head_ = SYNCED which means both gpu memory and cpu memory has mallced, so after callset_cpu_data
(set_gpu_data
), from the definition we could see the original mallced cpu(gpu) memory is set free, and assign a new data point, but the original gpu(cpu) memory has not be free, is this will cause memory leak?in addition, l
set_cpu_data
(set_gpu_data
) just transmit the pointer, we don't know the new memory block size, is this a problem?The text was updated successfully, but these errors were encountered: