Welcome, Guest. Please login or register.
Did you miss your activation email?
April 28, 2017, 07:11:37 AM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Chapter Study
| | |-+ Chapter 7 - More on Classes
| | | |-+ Program 7.6, why aFraction is not getting realesed too within For loop?
Pages: [1] Go Down
Author Topic: Program 7.6, why aFraction is not getting realesed too within For loop? (Read 1036 times)
Posts: 1

on: November 28, 2010, 08:03:15 PM

Here is part of Program 7.6 in page 154:

for (i = 1; i <= n; ++i) {
[aFraction setTo: 1 over: pow2];
sum2 = [sum add: aFraction];
[sum release]; // release previous sum
sum = sum2;
pow2 *= 2;

sum is getting release because "The old sum is then released" to avoid memory leakage, but why aFraction is not released too with the for loop? Seems it also changes value with every loop.

Thanks in advance to any help.
Last Edit: November 28, 2010, 08:04:51 PM by xiahou17 Logged
Hero Member
Posts: 3114

Reply #1 on: December 17, 2010, 05:32:44 PM

You really must read the stickied topic at the top of this category first, as it goes into a lot of detail on all of this.


Pages: [1] Go Up
Jump to:

Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.