Posts

Post not yet marked as solved
1 Replies
355 Views
I encounter memory leak in MPSCNNConvolution. This code create and destroy MPSCNNConvolution instance in a loop. I compiled with -objc-arc. So I excepted constant memory usage. But I observed increasing. How to prevent this memory leak?EnvironmentmacOS Mojave 10.14.6MacBookPro 13-inch 2018Intel Iris Plus Graphics 655 1536MBCodefor(int j=0;j<10000;j++){ MPSCNNConvolutionDescriptor * conv1descriptor = [MPSCNNConvolutionDescriptor cnnConvolutionDescriptorWithKernelWidth:kernel_x kernelHeight:kernel_y inputFeatureChannels:mem_cast(src_ptr)->shape.z outputFeatureChannels:mem_cast(dst_ptr)->shape.z neuronFilter:filter]; conv1descriptor.strideInPixelsX=stride_w; conv1descriptor.strideInPixelsY=stride_h; conv1descriptor.dilationRateX=dilation_w; conv1descriptor.dilationRateY=dilation_h; MPSCNNConvolution *conv1layer = [[MPSCNNConvolution alloc] initWithDevice:resource->m_device convolutionDescriptor:conv1descriptor kernelWeights:&weight->raw[0] biasTerms:bias flags:MPSCNNConvolutionFlagsNone]; printf("allocated size: %d\n",[resource->m_device currentAllocatedSize]); }Outputallocated size: 1164173312allocated size: 1164914688allocated size: 1165656064allocated size: 1166397440allocated size: 1167138816allocated size: 1167880192allocated size: 1168621568allocated size: 1169362944allocated size: 1170104320allocated size: 1170845696allocated size: 1171587072allocated size: 1172328448allocated size: 1173069824allocated size: 1173811200allocated size: 1174552576
Posted Last updated
.