Re: Memory not being released in a timely manner
The Allocations instrument should report objects with pending autoreleases as ordinary live objects. (Note that many objects with retain count == pending autorelease count will be retained again before the autorelease pool pops.) In OS X 10.8 and iOS 6 simulator, you can set environment variable OBJC_PRINT_POOL_HIGHWATER=YES to get debugging logs of the autorelease pool high-water mark on each thread. This can detect code that accumulates lots of autorelease garbage without spinning any pools. (The high-water mark is not checked until the pool is popped, so you'd have to actually finish the work to see the result.) Thanks for your comments Greg, very interesting. Unfortunately (in a sense!) the problem doesn't seem to happen on 10.8, so I can't reproduce the problem and get those debug logs. The Allocations instrument should report objects with pending autoreleases as ordinary live objects Do you happen to know if that's true of Allocations on 10.6? Is that definitely true for objects that have actually passed out of scope, and it would therefore be forbidden to re-retain them (if you know what I mean), but which haven't actually been freed behind the scenes? I'm not seeing Allocations report large amounts of memory. I assume that it should be reporting anything that is present within my 32-bit address space (i.e. I assume there isn't any way that external libraries could allocate memory that is in some way hidden from Allocations)? If that is the case, I suppose the only other possibility I can think of is that I am fragmenting the address space to such an extent that there is no way of allocating any further buffers (size of order 1MB). Currently my understanding of the problem is pretty much limited to: - Allocations claims only 300MB allocated memory - 1.2MB buffer cannot be allocated (insufficient memory) - Occurs when program is in background, and tickling autorelease pools at 1 second intervals makes the problem go away. - Occurs on 10.6, not on 10.8 I do have a solution in the form of the tickling, but I'd be very interested if you had any suggestions on ways I could dig further into the underlying cause. Cheers Jonny ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Move cursor to previous/next line in UITextView
In the iPhone/iPad simulator, you can use arrow-up and arrow-down keys on Mac to move the cursor to previous/next line in the UITextView. I'd like to create two buttons that implements the same functionalities. I didn't find any methods that let me do it easily. Any ideas on how to do this? Thanks, Peng ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Move cursor to previous/next line in UITextView
Hi, I'm guessing you mean just going down and up in the text view lines, not actual text lines? If that's the case, I don't believe that's doable. But if you want to go to the next or previous sentence, you can use the new line character set and some linguistic analysis. I recommend you check the WWDC '12 videos on the subject (Text and Linguistic Analysis). Best, Igor Ranieri On Jun 7, 2013, at 1:26 PM, Peng Gu pan...@gmail.com wrote: In the iPhone/iPad simulator, you can use arrow-up and arrow-down keys on Mac to move the cursor to previous/next line in the UITextView. I'd like to create two buttons that implements the same functionalities. I didn't find any methods that let me do it easily. Any ideas on how to do this? Thanks, Peng ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/igor.elland%40me.com This email sent to igor.ell...@me.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Memory not being released in a timely manner
On 7 Jun 2013, at 6:05 AM, Jonathan Taylor jonathan.tay...@glasgow.ac.uk wrote: [Greg Parker:] The Allocations instrument should report objects with pending autoreleases as ordinary live objects Do you happen to know if that's true of Allocations on 10.6? Is that definitely true for objects that have actually passed out of scope, and it would therefore be forbidden to re-retain them (if you know what I mean), but which haven't actually been freed behind the scenes? Greg Parker's lightest word would annihilate even my deepest thoughts, but this is my no-inside-information understanding of the semantics of the autorelease pool: It's just a broker with no insight into the state of the objects it holds. It does a retain when an object is presented, counts the retains it does, and does N releases when the pool is drained. Nothing special, and no way to decide whether all of the ownership count relates to what may be a stack of autorelease pools. There are optimizations — ARC includes a lot of them — but people have relied on those semantics for decades, and there's not much scope to change them. It has to act-as-if. If you already can pick out the object you're interested in in the Allocations history, and you turn retain tracking on, you can study the retain count and see how many times the object has been autoreleased. But Instruments has no way of flagging whether a retain pattern is other than what you expect/intend. The out-of-scope compile-time condition you suggest would be very hard to detect reliably. Clang may be insightful enough that it could instrument the object code to give the Allocations instrument clues, but that would be the next OS at the earliest, and doesn't help you on Snow Leopard. I have no clue about your root problem, which is bizarre according to what you've told us. My approach to such things is to blunder around until something suggests itself. It smells like you're doing a lot of processing with temporary objects, in a loop, without bracketing the loop body in @autoreleasepool{}, but I remember you saying you're not. [I remember vaguely that CG operates its own heap for image buffers, which is what your error message complains about. I dealt with it a long time ago, and I may be misremembering. What does the VM Tracker instrument say?] — F -- Fritz Anderson Xcode 4 Unleashed: 4.5 supplement for free! http://www.informit.com/store/xcode-4-unleashed-9780672333279 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Move cursor to previous/next line in UITextView
On Jun 7, 2013, at 4:26 AM, Peng Gu pan...@gmail.com wrote: In the iPhone/iPad simulator, you can use arrow-up and arrow-down keys on Mac to move the cursor to previous/next line in the UITextView. I'd like to create two buttons that implements the same functionalities. You should just be able to send it a fake key event whose key code is the appropriate arrow key’s. But I’m not nearly as familiar with events and responders in iOS as I am in Mac OS, so I couldn’t quickly find the method that receives key events. —Jens ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Memory not being released in a timely manner
It smells like you're doing a lot of processing with temporary objects, in a loop, without bracketing the loop body in @autoreleasepool{}, but I remember you saying you're not. Oh dear. Oh dear. You are right. I know this is what everybody has been telling me all along. I have a tiny one-line GCD block that is re-posted back onto the main event loop (for thread safety reasons), which I had overlooked. It was setting off a chain reaction of binding notifications etc that resulted in the image as displayed in the GUI being updated. An autoreleased image buffer involved in this wasn't being caught by an explicit pool, and so was falling foul of the problem described by Jeff Johnson whereby autoreleased objects weren't being cleaned up in a timely manner. So, wrapping that single line of code in an autorelease pool has fixed it. I'm so sorry for taxing everyone's patience on this one! Your suggestion of the VM Tracker instrument (which I had not spotted before) did bring up some interesting results though. These autoreleased image buffers that were causing the problem are definitely NOT reported at all by Allocations (live bytes stays stable at 250MB), but they do show up under VM Tracker as CG image and CG raster data - although I don't think there's a way of getting any further details about the buffers they provide the backing for? I do think it's interesting though (and a bit worrying) that the only way I could pinpoint the actual problem was by reading through the relevant bits of my code over and over - I wasn't able to glean any info from Instruments that really narrowed things down, other than to confirm that there were definitely image buffers accumulating somewhere. Jonny. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Memory not being released in a timely manner
On 7 Jun 2013, at 11:44 AM, Jonathan Taylor jonathan.tay...@glasgow.ac.uk wrote: I do think it's interesting though (and a bit worrying) that the only way I could pinpoint the actual problem was by reading through the relevant bits of my code over and over - I wasn't able to glean any info from Instruments that really narrowed things down, other than to confirm that there were definitely image buffers accumulating somewhere. This is the tragedy of the developer's existence. New tools make the day-to-day stuff much easier, but sometimes you must back off to 1970-era techniques, and audit your code. Tragedy never leaves us. http://www.joelonsoftware.com/articles/LeakyAbstractions.html -- Fritz Anderson Xcode 4 Unleashed: 4.5 supplement for free! http://www.informit.com/store/xcode-4-unleashed-9780672333279 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Memory not being released in a timely manner
On Jun 7, 2013, at 9:44 AM, Jonathan Taylor jonathan.tay...@glasgow.ac.uk wrote: Your suggestion of the VM Tracker instrument (which I had not spotted before) did bring up some interesting results though. These autoreleased image buffers that were causing the problem are definitely NOT reported at all by Allocations (live bytes stays stable at 250MB), but they do show up under VM Tracker as CG image and CG raster data - although I don't think there's a way of getting any further details about the buffers they provide the backing for? Those sorts of buffers are probably magical at the kernel level — one of the jobs of CG/Quartz is to shuffle pixmaps between CPU and GPU memory, and doing that efficiently is important to overall graphics performance. I wouldn’t be surprised if there were special types of memory pages that were optimized for this, that don’t live in normal address space. I just took a look at the Quartz Debug app and didn’t find any window for viewing memory usage, but someone might know of other tools. Sounds like it would be a good idea to add that to the regular memory-tracking instruments. —Jens ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Move cursor to previous/next line in UITextView
I didn't find the key events methods either. Seems Apple doesn't provide it in iOS. Is there any way to calculate the number of characters for lines in UITextView ? On Sat, Jun 8, 2013 at 12:37 AM, Jens Alfke j...@mooseyard.com wrote: On Jun 7, 2013, at 4:26 AM, Peng Gu pan...@gmail.com wrote: In the iPhone/iPad simulator, you can use arrow-up and arrow-down keys on Mac to move the cursor to previous/next line in the UITextView. I'd like to create two buttons that implements the same functionalities. You should just be able to send it a fake key event whose key code is the appropriate arrow key’s. But I’m not nearly as familiar with events and responders in iOS as I am in Mac OS, so I couldn’t quickly find the method that receives key events. —Jens ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
ASL appears to be broken on iOS; need a workaround
on iOS 6, I've been trying to add a couple of custom fields to the asl_msg instances I'm logging to the ASL database. I can create the log entries but when I issue a query to retrieve them later on (immediately, in the unit test), I get an aslresponse of zero. Same code works on Mac OS X 10.6 . In order to test this I used Mark Dalrymple's asl-log-n-query.m implementation from his third volume of Advanced Mac OS X Programming. It was a lot faster than lifting my code and wrapper for ASL out of my iOS project. My question is, does anyone know of a possible work-around for this issue? If you want to see the code, it can be downloaded here. http://borkware.com/corebook/ The sample is found in the folder for chapter 5. -Michael ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com