Live data from Hacker News

I Want My Memory, Apple

gamesfromwithin.com

11–20 of 24 posts

Re: I Want My Memory, Apple

#11
Wow. Yeah this seems like a staggeringly bad design.

Perhaps now that it's so obvious that the huge majority of apps are games Apple will put more thought into how to make the next iteration of the iPhone into a more capable gaming device.

Re: I Want My Memory, Apple

#12
post #3

I'm not sure the author is sufficiently familiar with the iPhone's memory management. The iPhone will terminate a user process if it consumes all available memory before the OS' low-memory handling has triggered low memory warnings, causing (in this order): - Running processes (including background processes) expunge caches, non-visible UI, etc. - Termination of Safari and Mail, which are kept running to improve the…

Well the way you use memory in a game is non deterministic, so "OS having time to free memory" is not a good enough answer. Although you're totally right that the IPhone wasn't designed as a console, so this process is probably good enough for most apps. Even more interresting than the post in itself (wich is very interresting) is the hack proposed by fishermen21 in the comments - http://gamesfromwithin.com/?p=428#co…

The iPhone doesn't swap because its flash memory is REALLY CRAPPY. It's terribly slow at even the easiest stuff like streaming reads. Swapping to it would cause epic grinding, so they don't do it (the flash wear that people usually trot out is irrelevant).

Re: I Want My Memory, Apple

#13
post #12

Earlier quoted context omitted.

Well the way you use memory in a game is non deterministic, so "OS having time to free memory" is not a good enough answer. Although you're totally right that the IPhone wasn't designed as a console, so this process is probably good enough for most apps. Even more interresting than the post in itself (wich is very interresting) is the hack proposed by fishermen21 in the comments - http://gamesfromwithin.com/?p=428#co…

The iPhone doesn't swap because its flash memory is REALLY CRAPPY . It's terribly slow at even the easiest stuff like streaming reads. Swapping to it would cause epic grinding, so they don't do it (the flash wear that people usually trot out is irrelevant).

While I agree with you, I'd like to know why you think flash wear is irrelevant.

Re: I Want My Memory, Apple

#14
post #12

Earlier quoted context omitted.

Well the way you use memory in a game is non deterministic, so "OS having time to free memory" is not a good enough answer. Although you're totally right that the IPhone wasn't designed as a console, so this process is probably good enough for most apps. Even more interresting than the post in itself (wich is very interresting) is the hack proposed by fishermen21 in the comments - http://gamesfromwithin.com/?p=428#co…

The iPhone doesn't swap because its flash memory is REALLY CRAPPY . It's terribly slow at even the easiest stuff like streaming reads. Swapping to it would cause epic grinding, so they don't do it (the flash wear that people usually trot out is irrelevant).

I don't know whether it is a reading issue. It might be a write issue, however. Flash can only allow so many write-cycles, and thrashing is a good way to guarantee flash running out of write-cycles.

Re: I Want My Memory, Apple

#15
post #3

I'm not sure the author is sufficiently familiar with the iPhone's memory management. The iPhone will terminate a user process if it consumes all available memory before the OS' low-memory handling has triggered low memory warnings, causing (in this order): - Running processes (including background processes) expunge caches, non-visible UI, etc. - Termination of Safari and Mail, which are kept running to improve the…

In my experience he's spot-on with 15MB - 18MB being the "safe" range. I've seen low-memory warnings past 18MB, and process death shortly thereafter. Relying on the OS to kill off background processes has not been reliable for me, at all.

Also, amusingly, the iPhone will occasionally hang the phone (requiring a reboot.. not just "wait for it to come back") rather than kill your process.

Re: I Want My Memory, Apple

#16
post #6

Earlier quoted context omitted.

Well the way you use memory in a game is non deterministic, so "OS having time to free memory" is not a good enough answer. Although you're totally right that the IPhone wasn't designed as a console, so this process is probably good enough for most apps. Even more interresting than the post in itself (wich is very interresting) is the hack proposed by fishermen21 in the comments - http://gamesfromwithin.com/?p=428#co…

I always assumed they were avoiding the non-trivial impact on lifespan of the internal flash.

They must use some wear leveling algorithm.

Also, this shouldn't really be much of a technical problem going forward since solid state drives clearly have swap space on them.

Re: I Want My Memory, Apple

#17
post #5

Earlier quoted context omitted.

Well the way you use memory in a game is non deterministic, so "OS having time to free memory" is not a good enough answer. Although you're totally right that the IPhone wasn't designed as a console, so this process is probably good enough for most apps. Even more interresting than the post in itself (wich is very interresting) is the hack proposed by fishermen21 in the comments - http://gamesfromwithin.com/?p=428#co…

Well the way you use memory in a game is non deterministic, so "OS having time to free memory" is not a good enough answer. Once the memory is made available to the foremost application, it will not be reclaimed by the operating system; As a game author you do not need to attempt to introduce determinism across all allocations, but instead ensure that initial allocations are not so rapid as to outpace the low-memory…

Yes. Instead of the "less enjoyable" experience of paging, we have the totally appletastic experience of disappearing applications, without warning.

Re: I Want My Memory, Apple

#18
Is an application supposed to be able to run on arbitrarily low memory? If not, I don't see the problem - you run out of memory, end the application with an Out Of Memory error.

Also, I wonder about the memory measurements on the iPhone? I only know from Java that the amount of free memory that the respective method call would return might be much lower than the actual memory available. That is because the garbage collection would sometimes only kick in once the memory would be urgently needed. So before you allocate an object, you might have only 1KB memory left (on paper), after you allocated it, suddenly you have 10MB.

I suspect a similar thing might be going on with the frequent complaints about the memory consumption of Firefox. Just because some system monitor claims that application X is using 100MB of memory doesn't mean application X is REALLY using 100MB of memory. Might be 99% "garbage" that could be collected at any moment.

Re: I Want My Memory, Apple

#19
post #18

Is an application supposed to be able to run on arbitrarily low memory? If not, I don't see the problem - you run out of memory, end the application with an Out Of Memory error. Also, I wonder about the memory measurements on the iPhone? I only know from Java that the amount of free memory that the respective method call would return might be much lower than the actual memory available. That is because the garbage co…

> Is an application supposed to be able to run on arbitrarily low memory?

Of course. Experience is everything on iPhones (and should be on most devices). If an app crashes, it's bad.

Re: I Want My Memory, Apple

#20
post #19
post #18

Is an application supposed to be able to run on arbitrarily low memory? If not, I don't see the problem - you run out of memory, end the application with an Out Of Memory error. Also, I wonder about the memory measurements on the iPhone? I only know from Java that the amount of free memory that the respective method call would return might be much lower than the actual memory available. That is because the garbage co…

> Is an application supposed to be able to run on arbitrarily low memory? Of course. Experience is everything on iPhones (and should be on most devices). If an app crashes, it's bad.

But it doesn't seem to be doable. As the original poster said,you can hardly unload a level in a game if there is insufficient memory. Sorry, but that requirement seems silly to me.
Post reply on HN