我想cudaMalloc
使用delete[]
;删除内核内部分配的数组;但是内存检查器显示访问冲突,数组保留在内存中,内核继续执行。
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
__global__ void kernel(int *a)
{
int *b = new int[10];
delete[] b; // no violation
delete[] a; // Memory Checker detects access violation.
}
int main()
{
int *d_a;
cudaMalloc(&d_a, 10 * sizeof(int));
kernel<<<1, 1>>>(d_a);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
cudaMalloc
和new
设备代码中分配的内存有什么区别?cudaMalloc
设备代码中分配的内存?谢谢