English 中文(简体)
Leak on append 格式
原标题:Leak on appendFormat

• 使用仪器探测某些泄漏,并发现一些泄漏,我无法解决;

        NSMutableString *textedetails = [[NSMutableString alloc] init];   ------->2,3%
                if([dico objectForKey:@"alertSerie"] != nil)
                    {[textedetails appendFormat:@"Numéro de Série: %@ 
",[dico objectForKey:@"alertSerie"]];}
                if([dico objectForKey:@"alertDate"] != nil)
                    {[textedetails appendFormat:@"Date de mise en service: %@ 
",[dico objectForKey:@"alertDate"]];}
                if([dico objectForKey:@"alertCli"] != nil)
                    {[textedetails appendFormat:@"Nom du client associé: %@ 
",[dico objectForKey:@"alertCli"]];}     ------->20,9%

                NSMutableString *texterecap = [[NSMutableString alloc] init];------->2,3%
                if([dico objectForKey:@"alertIndex"] != nil)
                {[texterecap appendFormat:@"Index du Compteur: %@ 
",[dico objectForKey:@"alertIndex"]];}
                if([dico objectForKey:@"alertE2day"] != nil)
                {[texterecap appendFormat:@"Energie produite aujourd hui: %@ 
",[dico objectForKey:@"alertE2day"]];}
                if([dico objectForKey:@"alertEmo"] != nil)
                {[texterecap appendFormat:@"Energie produite ce mois-ci: %@ 
",[dico objectForKey:@"alertEmo"]];}
                if([dico objectForKey:@"alertEy"] != nil)
                {[texterecap appendFormat:@"Energie produite cette année-ci: %@ 
",[dico objectForKey:@"alertEy"]];}
                if([dico objectForKey:@"alertCO"] != nil)
                {[texterecap appendFormat:@"CO2 économisé cette année: %@ 
",[dico objectForKey:@"alertCO"]];}
                if([dico objectForKey:@"alertPerfRel"] != nil)       
                {[texterecap appendFormat:@"Performance relative: %@ 
",[dico objectForKey:@"alertPerfRel"]];}      ------->74,4%

    [dico release];
details.numberOfLines=0;    // Pour mettre le nombre de lignes possibles à infini.
        details.text = [NSString stringWithFormat:@"%@", textedetails ];
        recapitulatif.numberOfLines=0;
        recapitulatif.text = [NSString stringWithFormat:@"%@", texterecap ];

        [textedetails release];
        [texterecap release];

......

- (void)dealloc {
    [login dealloc];
    [motdepasse dealloc];
    [responseData dealloc];
    [super dealloc];
}

这里:

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login et Mot de passe" message:@"Votre login et votre mot de passe sont enregistrés."delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
    [alert show];[alert release]; ------> 100%

我不理解这些泄漏和如何解决这些问题!

感谢我:D

http://www.un.org。

很显然,警示调查的泄漏是无漏的。

第一个泄漏事件再次暴露!

问题回答

在第一种情况下,在我看来,你没有释放两个变量:textedetailstexterecap。 (至少,你没有在所显示的法典中这样做)。 如果你显示更多的法典,我也许能够进一步帮助你,那么你在幕后做些什么呢?

页: 1 方法并不正确;应当:

- (void)dealloc {
    [login release];
    [motdepasse release];
    [responseData release];
    [super dealloc];
}

我不知道这是否也能够解决报告内容的问题,因为就物体而言,这很不寻常地称作dealloc/code>(即,我不知道它会有什么影响)。

此外,似乎你没有发布<代码>recapitulatif

在第二起案件中,我猜测的警示意见没有被正确驳回。 该守则是正确的;我只想试和执行代表议定书,看看是否实际采用<编码>-提示性意见:willDismissWithButtonIndex:方法。

在第一个例子中,你全心全意/不要求释放两名国家情报和安全局成员。 The UIAlertView used look ok.

Try using the function in Xcode. 它将指出发生泄漏的情况,并解释原因。

为什么你真的想要NSMutuableString

您可以使用

NSString *textedetails;;
NSString *texterecap;
if([dico objectForKey:@"alertSerie"] != nil){
    [textedetails stringByAppendingFormat:@"Numéro de Série: %@ 
",[dico objectForKey:@"alertSerie"]];
}
if(....){}
details.text = [NSString stringWithFormat:@"%@", textedetails ];
recapitulatif.numberOfLines=0;
recapitulatif.text = [NSString stringWithFormat:@"%@", texterecap ];


** this is autoreleased instance, so you do not need to call explicitly release on them **

你们只需要释放那些通过使用“许可”、“新”、“复印”或“互换性”(例如,所有物体、新目标或变式Copy)来创建的物体。

and in your second question, if you would have passed the delegate as self, would not be leak i guess. (according to your comment) i think some thing wrong then, because the below code for alert view will never leak.

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login et Mot de passe" message:@"Votre login et votre mot de passe sont enregistrés." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...