English 中文(简体)
核心基金会目标——潜在泄漏
原标题:Core Foundation object - Potential leak

我有以下几处(从Amplus Low Level file Management-Remov Aliases)

NSString *resolvedPath = nil;
...
resolvedPath = (NSString*)CFURLCopyFileSystemPath(resolvedUrl, kCFURLPOSIXPathStyle);
...
return resolvedPath;

建造和安装; 分析产生以下警告:

194:3 Potential leak (when using garbage collection) of an object allocated on line 187 and stored into  resolvedPath 

详细情况如下:

187:32 Call to function  CFURLCopyFileSystemPath  returns a Core Foundation object with a +1 retain count (owning reference).  Core Foundation objects are not automatically garbage collected

194:3 Object returned to caller as an owning reference (single retain count transferred to caller)

194:3 Object allocated on line 187 and stored into  resolvedPath  and returned from method  getTarget:  is potentially leaked when using garbage collection.  Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector

我是否有记忆泄漏?

如果是这样,我如何确定?

如果我不怎么防止警告?

最佳回答

我是否有记忆泄漏?

您应认为这是一种泄漏。 在GC中,不保证在采集器上登记一种脂肪。 仅涉及一系列类型(表面切除物体)。 您应假设在采集器上登记的剪辑类型或复印件。 您是不是在采集器上登记的彩虹功能中回归的,不是披露的(可能是因为动物类型是一种f类)。

如果是这样,我如何确定?

利用CFMake 电缆或NSMake 电缆

问题回答

仅提醒您,为<代码>resolvedPath 而设定的标的,以<代码>中包含的1,除非您的方法从new alloccontains份eter开始。 没有任何东西可以知道,它处理的是<条码>所载明的物体,因此,它永远不会得到<条码>的<>发布<>。

将其方法名称从get改为newTarget/code>。





相关问题
GarbageCollector, Dispose or static Methods?

I developed a few classes last month. They grow big (round 30-40 Methods each class). I never take a thought of Memory Leaks, GarbageColletor or something like this (I must say this is my first own ...

Can t free memory of NSData object

i m new to xcode / cocoa and even objective-c thus my question might be stupid. Im trying to write a program that will hash files in a folder. I looked around and found a way to load a file via a ...

Alternative to Java

I need an alternative to Java, because I am working on a genetics-calculation project. It takes a lot of memory and the most of the cpu time. And therefore it won´t work when I deploy it on a server, ...

Question about the garbage collector in .NET (memory leak)

I guess this is very basic but since I m learning .NET by myself, I have to ask this question. I m used to coding in C, where you have to free() everything. In C++/.NET, I have read about the garbage ...

Does garbage collection work with the Go compiler (gc)?

I noticed that garbage collection is not yet implemented in gccgo. http://golang.org/doc/gccgo_install.html#Unimplemented Does the standard Go compiler (gc) support garbage collection yet?

doubts regarding Memory management in .net

I m learning about Memory management in C# from the book "Professional C#" The presence of the garbage collector means that you will usually not worry about objects that you no longer need; ...