Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-26-2009, 02:58 AM   #1 (permalink)
New Member
 
Join Date: Apr 2009
Posts: 1
iTom is on a distinguished road
Default Problems with UIScrollView and a memory leaks

Hi developers,

I am working on an application which uses UIScrollViews to display 8 UIViews with some labels and images (I'm not using the imageNamed method...). Each UIScrollView is inside an UIViewController.

The user can drill down in the data, so the old UIViewController will be released and a new will be created.

Unfortunately there is somewhere a memory leak, which is not displayed in Instruments.

Inside the controller I try to release the scrollView in the dealloc method, but the scrollView, and all underlying views with the images and labels are not being released and the memory consumption grows.

Here is a part the outer Controller which handles the drilldown:
Code:
- (void)drillDown:(int)timePeriod {
	
	//	NSLog(@"releasing old statisticsViewController");
	if ( statisticsViewController != nil && [[statisticsViewController view] superview] != nil ) {
		[[statisticsViewController view] removeFromSuperview];
	}
	
	[statisticsViewController release];
	
	NSLog(@"allocation new viewcontroller");
	
	statisticsViewController = [[StatisticsViewController alloc] initWithNibName:nil bundle:nil withTimePeriod: timePeriod];
	
	if ( statisticsViewController != nil && [[statisticsViewController view] superview] != nil ) {
		NSLog(@"still connected to superview!!");	
	}
		
	[view addSubview: [statisticsViewController view]];
}
and this the code from the statistic controller for the creating and filling of the uiscrollview
Code:
		
		scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 358)];
		[scrollView setPagingEnabled: YES];
		[scrollView setContentSize: CGSizeMake(320.0f * numberOfPages, 358.0f)];
		[scrollView setShowsHorizontalScrollIndicator: YES];
		[scrollView setShowsVerticalScrollIndicator: NO];
		[scrollView setScrollsToTop: NO];
		[scrollView setDelegate: self];

// add the views to the scroll view
		for ( int i=0; i < numberOfPages; i ++ ) {
			NSString* currentDate = (NSString*)[statisticDates objectAtIndex:i];
			StatisticsView* statisticsView = [[StatisticsView alloc] initWithFrame:CGRectMake(0, 0, 320, 358) withDate:currentDate withTimePeriod:timePeriod];
			[statisticsView autorelease];
			if (nil == statisticsView.superview) {
				CGRect frame = scrollView.frame;
				frame.origin.x = frame.size.width * i;
				frame.origin.y = 0;
				statisticsView.frame = frame;
			}
			[scrollView addSubview:statisticsView];
		}
I think the issue is because of the allocation and the autorelease of those "StatisticsView"s?

I spend the last couple of day in rebuilding and rearranging the code but I don't get rid of the growing memory usage and the allocated objects. I read the memory guide from apple and googled a lot, but without any success

Any hint would be great!

Thanks for your help

Tom
iTom is offline   Reply With Quote
Reply

Bookmarks

Tags
leak, memory, problem, uiscrollview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 316
7 members and 309 guests
blueorb, givensur, guusleijsten, jbro, mer10, n00b, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:00 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0