We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
不知道为什么,把下面函数返回的 unsigned char* 值给cv::Mat之后会导致内存泄漏
unsigned char* JpegCoderImage::buffer() { nvjpegImage_t* img = ((nvjpegImage_t*)(this->img)); size_t size = height * width * 3; unsigned char* buffer = (unsigned char*)malloc(size); cudaMemcpy(buffer, img->channel[0], size, cudaMemcpyDeviceToHost); return buffer; }
JpegCoderImage* jpgImage = decode((const unsigned char *)(pchData.data()), file_size); img = cv::Mat(jpgImage->height, jpgImage->width, CV_8UC3, jpgImage->buffer()); delete jpgImage;
好像是 buffer 导致内存无法释放?
我现在的做法是:
unsigned char* JpegCoderImage::buffer() { nvjpegImage_t* img = ((nvjpegImage_t*)(this->img)); //size_t size = height * width * 3; //unsigned char* buffer = (unsigned char*)malloc(size); //cudaMemcpy(buffer, img->channel[0], size, cudaMemcpyDeviceToHost); return img->channel[0]; }
JpegCoderImage* jpgImage = decode((const unsigned char *)(pchData.data()), file_size); img = cv::Mat(jpgImage->height, jpgImage->width, CV_8UC3); cudaMemcpy(img.data, jpgImage->buffer(), jpgImage->height * jpgImage->width * 3, cudaMemcpyDeviceToHost); delete jpgImage;
The text was updated successfully, but these errors were encountered:
No branches or pull requests
不知道为什么,把下面函数返回的 unsigned char* 值给cv::Mat之后会导致内存泄漏
好像是 buffer 导致内存无法释放?
我现在的做法是:
The text was updated successfully, but these errors were encountered: