ios - 如何从内存中清除 +(UIImage *)
问题描述
是否可以清除以下示例代码的内存?
+(UIImage *) makeGray:(UIImage *) image {
// Transform UIImage to cv::Mat
cv::Mat imageMat;
UIImageToMat(image, imageMat);
//Transform image to grayscale
cv::Mat grayMat;
cv::cvtColor(imageMat, grayMat, CV_BGR2GRAY);
//draw contour
if(shape[i].size() >0 && ....)
{
drawContours(....)
//get largest contour
if(a > largetest_area)
{
largest_area = a;
largest_contour_index = i;
bounding_rect = boundingRect(contours[i]);
largest_contour_value = boundingRect(contours[largetst_contour_index])
return MatToUIImage(grayMat);
}
我试过grayMat.release()
没有成功。看起来我可以delete[] 'function name';
但是,我无法调用该函数。
解决方案
内存问题不会显示为 CPU 使用率。使用带有“Leaks”模板的 Instruments.app 来查找内存问题,并使用“Profiler”来查找性能问题。
推荐阅读
- python - 如何识别这个 div 标签?
- excel - 从所有工作表中提取一些数据并复制到另一张工作表中
- c++ - ZMQ REP 如何释放 CPU 时间
- laravel - 一次性将信息存储到 order 和 order_details 表中
- java - 依赖项没有从导入的 jar 文件反映到我的 Spring Boot 项目中
- android - 预期为 BEGIN_OBJECT,但在路径 $[0] 处是字符串
- kubernetes - Kubernetes 容器运行时网络未准备好
- python - 在 Numpy 中计算累积标准差
- tcl - 将二进制数据变量转换为字节列表
- firebase - 如何使用带有自定义 URL 方案的动态链接?