Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

iphone - memory leak using MBProgressHUD -


i using mbprogresshub, variations on code found here.

some things code:

  • the code in app delegate
  • a number of other classes call it
  • i'm using asynchronous nsurlconnection
  • i not declare it: @property (nonatomic, retain) mbprogresshud *hud;
  • i not: @synthesize hud;
  • (and of course not release in dealloc)

i use follows:

- (void)setsearchingmode:(bool)issearching {     // when network action, toggle network indicator , activity indicator     if (issearching) {         [uiapplication sharedapplication].networkactivityindicatorvisible = yes;          uiwindow *thewindow = [uiapplication sharedapplication].keywindow;         hud = [[mbprogresshud alloc] initwithwindow:thewindow];         [thewindow addsubview:hud];          //hud.labeltext = @"connecting";         [hud show:yes];     } else {         [uiapplication sharedapplication].networkactivityindicatorvisible = no;          [hud hide:yes];         [hud removefromsuperview];         [hud release];     } }  - (void)setsearchingtext:(nsstring *)whattosay {     hud.labeltext = whattosay; } 

i sure code causing memory management problem somewhere. in crash log, get:

exception type: exc_bad_access (sigbus)
exception codes: kern_protection_failure @ 0x0000000c

0 libobjc.a.dylib 0x000027d8 objc_msgsend + 16
1 0x00003120 -[myappdelegate setsearchingmode:] (myappdelegate.m:363)
2 0x00003458 -[myappdelegate connectiondidfinishloading:] (myappdelegate.m:341)
3 foundation 0x00032896 -[nsurlconnection(nsurlconnectionreallyinternal) senddidfinishloading] + 62
4 foundation 0x00032818 _nsurlconnectiondidfinishloading + 72

in connectiondidfinishloading call:

[self setsearchingmode:no]; 

i tried making property accessors hud, not able around line "[mbprogresshud alloc] initwithwindow" - , don't want keep on alloc'ing ivar!

thanks, if can point me in better direction here..

if happen end sequence of:

[self setsearchingmode:yes]; [self setsearchingmode:no]; [self setsearchingmode:no]; 

that code crash described because of dangling reference hud. when [hud release];, add hud = nil; after line.

it isn't memory leak; over-release. or, more likely, dangling reference.

(and of course not release in dealloc)

why not? if retain it, better release it!


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -