请允许我向我提出一些建议,说明我为什么会把记忆泄露到这个线上:
OK, so this is more of an answer than a question, but after asking this question, and pulling together the various bits from Dustin Campbell, Egor, and also one last tip from the IObservable/Rx/...
请允许我向我提出一些建议,说明我为什么会把记忆泄露到这个线上:
如果你看从建设和分析中发出的警告,你就会注意到,警告实际上适用于你的法典第38条,而不是显示信息的第39条。
第38条,请<代码>alloc,即,请将记忆分配给
Every alloc
, new
, copy
, and retain
requires a matching release
or autorelease
. So, the compiler is warning you that you have called alloc
but haven t called a corresponding release
anywhere.
您可在第38行文中添加<代码>autorelease:
self.tableView.backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Back_01.jpg"]] autorelease];
如果您不想使用<代码>autorelease。 那么,你就可以利用这样的东西:
UImageView *bgImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Back_01.jpg"]];
self.tableView.backgroundView = bgImage;
[bgImage release];
唯一真正的区别是,在汽车库排水时,<代码>autorelease等到跑道结束时,而电话release
则有可能很快释放记忆。
The UIImageView
on line 38 is leaking. You should add autorelease
, like so:
self.tableView.backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Back_01.jpg"]] autorelease];
OK, so this is more of an answer than a question, but after asking this question, and pulling together the various bits from Dustin Campbell, Egor, and also one last tip from the IObservable/Rx/...
I m using getImageData/putImageData on a HTML5 canvas to be able to manipulate a picture. My problem is that the browser never seems to free any memory. Not until I close the tab (tested in Chrome and ...
I have read that the following code causes memory leak. But did not understand why. CComBSTR str; pFoo->get_Bar(&str); pFoo->get_Baf(&str); How does it cause a leak when we are not ...
I m finding leaked heap blocks by using the following command in WinDbg !heap –l With each leaked heap block I get, I m running to following to get the stack trace. !heap -p -a leakedheapblock The ...
I m at my first experiences with iPhone development. I wrote some basic code to test the NSScanner class, and now I was looking into the Leaks tool. It seems that this code is leaking, when in the ...
With RAM typically in the Gigabytes on all PC s now, should I be spending time hunting down all the small (non-growing) memory leaks that may be in my program? I m talking about those holes that may ...
How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...
System: Windows XP SP3, .NET 3.5, 4GB RAM, Dual 1.6gHz I have a WPF application that loads and transitions (using Storyboard animations) extremely large PNGs. These PNGs are 8190x1080 in resolution. ...