{"id":2802,"date":"2022-08-30T15:27:54","date_gmt":"2022-08-30T15:27:54","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/02\/17\/iosmemoryview-the-original-page-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:27:54","modified_gmt":"2022-08-30T15:27:54","slug":"iosmemoryview-the-original-page-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/iosmemoryview-the-original-page-collection-of-common-programming-errors\/","title":{"rendered":"ios,memoryView the original page-Collection of common programming errors"},"content":{"rendered":"<h3>UnKnown Error<\/h3>\n<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2642b4d2d630dd9ab17d60e48b9fcb30?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nqiyu<br \/>\nios objective-c performance 2014-2-17 2:02:36<br \/>\nThis question already has an answer here:Difference between self.ivar and ivar?4 answers@interface Person : NSObject @property(nonatomic, assign) CGFloat salary; @end@implementation Person &#8211; (void)addSalary:(CGFloat)s {_salary += s; **\/\/method 1**self.salary += s; **\/\/method 2** } @endI wonder which is more efficient between method 1 and 2? Would the compiler do some optimisation work to make them have the same performance?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f968c099f4db7234d5c0b995c8a5d60d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nqegal<br \/>\niphone objective-c ios cocoa-touch retina-display 2014-2-17 1:03:57<br \/>\nI Have an app full of images, but when you run it on retina displays it gets pixelized, I have the same images with double resolution, but I don&#8217;t know ho to add them to my project&#8230;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/81d2c0d1e169fccb63893706ef70db19?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nrmaddy<br \/>\nios uiview extend util 2014-2-16 23:54:02<br \/>\nI would like to add one property to UIView. I know I could subclass an UIView but as I want to add onelly one property I would like just to extend it.I try like this :@interface UIView (Util) @property(nonatomic, assign) BOOL isShow; @end@implementation UIView (Util) @dynamic isShow;-(void)setIsShow:(BOOL)isShow{self.isShow = isShow; } @endbut it doesn&#8217;t work. It throw an exception : Thread 1: EXC_BAD_ACCESS(code=2,address,&#8230;)<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3b687a35025c05dbc7627af428dff0da?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJohn Topley<br \/>\nios objective-c xcode uikit segue 2014-2-16 18:21:33<br \/>\nCan someone more knowledgeable than I explain performSegueWithIdentifier:sender: for me? I need to switch views (and classes) and also carry a few NSStrings and IDs over to that view&#8217;s class. I was wondering if this is possible with performSegueWithIdentifier:sender:Thanks!<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/639ced0d6d8b40ff2472650a8e349145?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJim<br \/>\nios objective-c automatic-ref-counting sudzc 2014-2-16 17:07:32<br \/>\nEdit &#8211; I&#8217;ve tracked the below issue to a 64-bit vs 32-bit architecture issue&#8230; see my posted answer for how I resolvedI&#8217;ve used SudzC to generate SOAP code for a web service. They supply you with a sample application, which I was able to use successfully, both on device and simulator.I then started building out my app. I imported the SudzC generated files into a new XCode project using the blank application template (with CoreData and ARC enabled).I got the first SOAP request up and running &#8212;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4243850fb352160089d0576d9479a2ff?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nLuke Taylor<br \/>\niphone ios objective-c ipad 2014-2-16 16:24:35<br \/>\nI&#8217;m starting to code for iOS and I was wondering, say if I read user provided password value as such:NSString* strPwd = UITextField.text;\/\/Check &#8216;strPwd&#8217; &#8230;\/\/How to clear out &#8216;strPwd&#8217; from RAM?I just don&#8217;t like leaving sensitive data &#8220;dangling&#8221; in the RAM. Any idea how to zero it out?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fb6c69436d239304e7c44db78ea2ea36?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nThomas Clayson<br \/>\nios key-value-observing 2014-2-16 15:33:04<br \/>\nWhenever a property on my object is changed or updated I want to change a variable (nonce variable). This nonce is time-based. So everytime a property is updated this nonce gets updated to the current time.Is there any way to automatically listen for all key changes on my object? Or will I have to manually maintain all keyvalue observers for each property separately?Many thanks<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5ae09a7b73edd93a4ec40a5c1b29e728?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTill<br \/>\niphone ios memory-management 2014-2-16 14:48:19<br \/>\nI&#8217;m interesting a size of memory, allocing with some Objective-C classes. For example : Is [NSString stringWithString:@&#8221;2&#8243;] bigger than [NSNumber numberWithInt:2] or not? And how much [NSNumber numberWithInt:2] bigger than int num=2 ? Are there some documentation from Apple about this question? I think, this information is very important for memory optimisation.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/771d6811baa1b117dd8a5ff0708fc66b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nYar<br \/>\nobjective-c ios 2014-2-16 14:35:44<br \/>\nNote: This other question seems relevant but it&#8217;s not: When does an associated object get released?I&#8217;m adding a second description to a UIView instance as follows:- (void) setSecondDescription:(UIView*)view description2:(NSString*)description2 {objc_setAssociatedObject (view,&amp;key,description2,OBJC_ASSOCIATION_RETAIN); }- (NSString*) secondDescription:(UIView*)view {return (id)objc_getAssociatedObject(view, &amp;key); }If the UIView deallocs, will the associated description 2 get dealloced<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/81d2c0d1e169fccb63893706ef70db19?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nrmaddy<br \/>\nios objective-c methods boilerplate 2014-2-16 14:33:29<br \/>\nI have a simple UIViewController with 9 UIImageViews. When each UIImageView is pressed a method (or function) is called. This all works fine but the problem is that I have too much boiler plate code now.In my viewDidLoad method I have 9 UITapGestureRecognizer to detect when any of my 9 UIImageViews are pressed. They then call a method to run. Here is my code:UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imagepressed1:)]; [picview_1 addGesture<\/li>\n<\/ul>\n<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d2075409d490db9d31134d2cbf7b53ba?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPaulDaviesC<br \/>\nlinux memory c function 2014-2-16 22:57:28<br \/>\nI wrote a simple program as below and straced it.#include&lt;stdio.h&gt; int foo(int i) {int k=9;if(i==10)return 1;elsefoo(++i);open(&#8220;1&#8221;,1); } int main() {foo(1); }My intention in doing so was to checkout how is memory allocated for the variables (int k in this case) in a function on a stack. I used an open system call as a marker. The output of strace was as below:execve(&#8220;.\/a.out&#8221;, [&#8220;.\/a.out&#8221;], [\/* 25 vars *\/]) = 0 brk(0) = 0x8653000 access(&#8220;\/etc\/ld.so.nohwcap&#8221;,<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/66e6a2e79abe37eaab4d911116e914ad?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nioeric<br \/>\nc++ c memory operating-system 2014-2-16 17:01:19<br \/>\nI was doing some experiments on the heap address growth, and something interesting happened. (OS: CentOS, ) But I don&#8217;t understand, why this happened? Thanks!This is what I did first:double *ptr[1000]; for (int i=0;i&lt;1000;i++){ptr[i] = new double[**10000**];cout &lt;&lt; ptr[i] &lt;&lt; endl; }The output is incremental(for the last few lines):&#8230;. &#8230;. 0x2481be0 0x2495470 0x24a8d00 0x24bc590 0x24cfe20 0x24e36b0 0x24f6f40 0x250a7d0 0x251e060Then I changed 10000 to 20000:double *ptr[1000]; for<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2a04086d7656ac97e09c20c4fe4d8266?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsharptooth<br \/>\nc++ visual-c++ memory heap-fragmentation 2014-2-16 15:17:44<br \/>\nHeap fragmentation can cause a server application that is expected to run continuously for many months to suddenly start malfunctioning thinking that it&#8217;s out of memory.Let&#8217;s assume that I&#8217;ve done my best to minimize runtime heap fragmentation in my VC++ server application but still it builds up and causes problems. I could for example automatically restart the application every month or every half million requests processed &#8211; safely stop it and safely start again with a new heap. What else can<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a23eaea0bc18dd5eb54ca08b508bf9f9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nFaken<br \/>\ndebugging visual-c++ memory inspector 2014-2-16 14:58:39<br \/>\nI&#8217;m using Intel Inspector to check for memory issues with my program and I keep running into &#8220;uninitialized memory access&#8221; errors in the MSVCR90D.dll modules but when I click on that error, it says no source could be displayed. Any ideas what I&#8217;m doing wrong to cause this to happen?I have a suspicion that it has something to do with my read in\/output functions but how can I be sure?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/43ba952e9abb5deec22eae7fd27707e5?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nzeion<br \/>\nc memory memory-management memory-address 2014-2-16 14:05:19<br \/>\nIs it possible to print out what is stored at a specific memory address? For example I want to know what is stored at the address 0x7FFFFF0. How would I do this? I do not know what is stored at the address before hand ie. it could be an int or char or a null terminator.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1795ab274422f6bd93a5d5ab961143dc?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBhesh Gurung<br \/>\njava performance memory garbage-collection jvm 2014-2-16 8:15:04<br \/>\nI have a Map in memory that stores my objects. I&#8217;d like to flush to memory when I&#8217;m running out of memory. I&#8217;m doing this right now:void add(K key, V value) {if (underPressure()) {flush(innerMap);}innerMap.add(k, v); }boolean underPressure() {Runtime rt = Runtime.getRuntime();long maxMemory = rt.maxMemory();long freeMemory = rt.freeMemory();return (double) freeMemory \/ maxMemory &lt; threshold; }As underPressure() is called at each insert, how expensive is it? To my understanding, as it&#8217;s an app<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8f1ba1dc2f184e1340424ddcdd7bee66?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nthelight<br \/>\nperformance delphi memory delphi-7 delphi-xe 2014-2-16 6:05:43<br \/>\nIs there a real performance gain when I turn {$IMPORTEDDATA} off ?The manual only says this: &#8220;The {$G-} directive disables creation of imported data references. Using {$G-} increases memory-access efficiency, but prevents a packaged unit where it occurs from referencing variables in other packages.&#8221;Update:Here is more info I could find:&#8221;The Debugging section has the new option Use imported data references (mapped to $G), which controls the creation of imported data references (increasing memory<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/98962f66952b868cd45e68a298568e24?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nglaz666<br \/>\njava memory tomcat 2014-2-15 23:02:05<br \/>\nI know there are several memory types that Tomcat uses when running.The only I have ever used &#8211; java heap. It can be controlled through JAVA_OPTS env property with something like &#8216;-Xmx128M -Xms64M&#8217;I have found that there is also -XX:MaxPermSize, -XX:MaxNewSize and etc.The reason I&#8217;m asking is that I&#8217;m trying to launch Tomcat5.5 on 200Mb RAM memory (it is VPS server). I have setup java heap size with &#8216;-Xmx128M -Xms64M&#8217;, but it seems that right from startup it consumes more than that (if ever can<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/420f6c340192b9e0168716c9ae87f182?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJava Enthusiast<br \/>\njava string memory memory-management garbage-collection 2014-2-15 21:07:48<br \/>\nProfiling the application I figured out that there are a lot of strings on heap. In my situation, strings are created on heap and not interned and they are not literals. Are there are specific GC tuning techniques to follow when the number of strings in the application are very high. I stumbled across the GC settings -XX:+UseCompressedStrings or -XX+UseStringCache but not sure this will help. Did any body try these settings?java version &#8220;1.6.0_22&#8221; Java(TM) SE Runtime Environment (build 1.6.0_22-<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fbc0a27049271cadb696ad956decbc79?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBo Persson<br \/>\njava linux memory operating-system ram 2014-2-15 10:59:30<br \/>\nI&#8217;m new to Linux and have a question about memory limitations. As I know, in Windows you can only have 2.8 GB used in the 32bit version of OS, but what about Linux &#8211; is it 4 GB or less too?I&#8217;m particularly interested in Java application run in RHEL5. But if you have answers about other technologies &#8211; that would be awesome to listen to.<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2014-02-17 00:15:57. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>UnKnown Error qiyu ios objective-c performance 2014-2-17 2:02:36 This question already has an answer here:Difference between self.ivar and ivar?4 answers@interface Person : NSObject @property(nonatomic, assign) CGFloat salary; @end@implementation Person &#8211; (void)addSalary:(CGFloat)s {_salary += s; **\/\/method 1**self.salary += s; **\/\/method 2** } @endI wonder which is more efficient between method 1 and 2? Would the compiler [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2802","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2802"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2802\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}