Live data from Hacker News

My first six months of programming: from man-rodent to partyman

whitakerblackall.com

31–37 of 37 posts

Re: My first six months of programming: from man-rodent to partyman

#33
post #21

Earlier quoted context omitted.

Isn't there a huge memory leak? Creating a new pointer on each iteration without keeping track of them. I might be wrong I've been doing games in CL for some time now.

With a few exceptions, pointers returned by methods in Objective-C are assumed to be autoreleased. That means their reference count will be decremented at the end of the event loop. But if OP is expecting a lifetime of learning, he might want to push a new autorelease pool for each iteration.

Or just release it. If you're sure it's autoreleased then retain/release it. If you're not sure, just set it to autorelease before you retain/release it.

Re: My first six months of programming: from man-rodent to partyman

#34

Earlier quoted context omitted.

With a few exceptions, pointers returned by methods in Objective-C are assumed to be autoreleased. That means their reference count will be decremented at the end of the event loop. But if OP is expecting a lifetime of learning, he might want to push a new autorelease pool for each iteration.

Or just release it. If you're sure it's autoreleased then retain/release it. If you're not sure, just set it to autorelease before you retain/release it.

retain/release on an autoreleased object won't make it get destroyed any faster. You still have to wait for the event loop to cycle (or push/pop your own autorelease pool).

Re: My first six months of programming: from man-rodent to partyman

#36
After 15 years in the corporate world I've almost forgotten those exciting early days of programming. This article brought back the joy I felt when I figured out how to make the bad guy "home in" on the good guy - that was a turning point for me!

I need to do some true recreational programming again - just for the pure joy of it.

Re: My first six months of programming: from man-rodent to partyman

#37

Earlier quoted context omitted.

Or just release it. If you're sure it's autoreleased then retain/release it. If you're not sure, just set it to autorelease before you retain/release it.

retain/release on an autoreleased object won't make it get destroyed any faster. You still have to wait for the event loop to cycle (or push/pop your own autorelease pool).

That's correct. That's something I read, have repeated but never bothered to actually test.
Post reply on HN