Memory Management release or autorelease?

Hi!
Im am finishing my app and starting to optimize and analyze my code with instruments..
There are still some things concerning memory management I dont understand..
1. I'm starting a urlConnection. My class implements the connection delegate, so, it is "waiting" for the response data in a background thread. If I am clicking "build & analyze", XCode complains about a potential memory leak for the getMessageHeaderConnection variable if I am not releasing it. Should I release it (variant 1), or should I autorelease it (variant 2)? Releasing means, that the object is destroyed, right? But: If am releasing it (variant 1) my getGroupMsgHeaders:groupId method doesn't stop immediately, it is still alive, but it should be dead, right?
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
GetMessageHeaderConnection *getMessageHeaderConnection = [[GetMessageHeaderConnection alloc] initWithDelegate:self];
getMessageHeaderConnection.currentUserLocation = currentUserLocation;
[getMessageHeaderConnection getGroupMsgHeaders:groupId];
[getMessageHeaderConnection autorelease]; //variant 2
[getMessageHeaderConnection release];//variant 1

sommeralex wrote:
1. I'm starting a urlConnection. My class implements the connection delegate, so, it is "waiting" for the response data in a background thread.
Are you sure that is the best strategy? Threading can make things painfully difficult and complicate your life, including where autorelease is concerned. You should be able to do this on the main thread.
If I am clicking "build & analyze", XCode complains about a potential memory leak for the getMessageHeaderConnection variable if I am not releasing it. Should I release it (variant 1), or should I autorelease it (variant 2)?
Neither, apparently.
Releasing means, that the object is destroyed, right?
Yes.
But: If am releasing it (variant 1) my getGroupMsgHeaders:groupId method doesn't stop immediately, it is still alive, but it should be dead, right?
If that is running in another thread, then it will continue running, but "self" will be invalid and will crash when you access it. Don't bother testing it, because it could work just fine in debug mode. It will still crash when someone else tries it.
Standard procedure in this case is to make sure that the method running in the background thread retains itself until the method is done. Many of the built-in threading methods or other asynchronous methods (such as NSInvocation) will do that automatically. You can study the documentation to find out where that happens.

Similar Messages

  • Memory Management Questions

    Hello All!
    I read the Memory Management Programming Guide for Cocoa - several times. But some things are still not really clear.. I would like and need to have a deeper understanding. So, I hope someone could help me The problem is that I had to get rid of several (..) memory leaks in my app, and now I am a bit confused and unsure about my skills at all..
    1.
    What is the difference between sayHello1,sayHello2,getHello1,getHello2,getHello3 and which one is "better" (and why) - please dont try to interprete the logic/sense of the methods itself
    - (NSString *) sayHello1{
    return [[[NSString alloc] initWithString:@"Hello"] autorelease];
    - (NSString *) sayHello2{
    return [[[NSString alloc] initWithString:@"Hello"] retain];
    - (void) getHello1{
    NSString *hello = [self sayHello1];
    [hello release];
    - (void) getHello2{
    NSString *hello = [self sayHello2];
    [hello release];
    - (void) getHello3:(NSString *)hello{
    [hello retain];
    NSLog(@"%@", hello);
    [hello release];
    Concerning this, there are several questions:
    2.
    If I have to release everything I retain/alloc, why then do I have a memory leak, if am returning an object (which was allocated with alloc and init) from a method without autorelease. The object is still in memory. But the following method wont work. What I accept. But the object is, if returned, not reachable, but also not released. Why then is it not automatically released? (i dont mean autorelease)
    - (NSString *) sayHello1{
    return [[NSString alloc] initWithString:@"Hello"]];
    - (void) getHello{
    NSString *hello = [self sayHello1]; //wont work. the object is not there, but also not released. WHERE is it?
    [hello release];
    3.
    When is a delegate method released, if I have no variable I can use to "release"? So, if I have nothing to access the delegate like a NSURLConnection delegate?
    should I, for example, call a [self release]?
    - (void)startParser{
    Parser *parser = [[Parser alloc] init];
    [parser start];
    //should I use a [parser autorelease or retain] here?
    - (void)parserDidEndDocument:(NSXMLParser *)parser{
    //do somethings with the parserstuff
    [self release];
    4.
    *And the last question:*
    Where can I see in instruments, which elements have retain counts > 1 and potential leaks? I was reading the instruments guide but there is only theoretical stuff. No practical guides like: your app should not have/use more than x megabyte ram.. for example: my app gets slower and slower the longer a i use it. -> this indicates memory leaks..

    A Leak is only a leak if the reference to the object is lost.
    https://devforums.apple.com/message/189661#189661

  • Memory management in plugins using Cocoa

    Hello,
    In Obj-C memory management guide stated: "If you spawn a secondary thread, you must create your own autorelease pool as soon as the thread begins executing; otherwise, you will leak objects."
    I assume that it also applies to Acrobat Plugins? What are the guidelines of using NSAutoreleasePools in plugins and is there any specific things in plugins' memory manamgement?

    If you have multiple subvis grabbing 200MB each you might try using the "Request Deallocation" function so that once a vi is done processing it releases the memory.
    LabVIEW Help: "When a top-level VI calls a subVI, LabVIEW allocates a data space
    of memory in which that subVI runs. When the subVI finishes running, LabVIEW
    usually does not deallocate the data space until the top-level VI finishes
    running or until the entire application stops, which can result in out-of-memory
    conditions and degradation of performance. Use this function to deallocate the
    data space immediately after the VI completes execution."
    Programming >> Application Control >> Memory Control >> Request Deallocation
    I think it first appeared in LabVIEW 7.1.
    Message Edited by Troy K on 07-14-2008 09:36 AM
    Troy
    CLDEach snowflake in an avalanche pleads not guilty. - Stanislaw J. Lec
    I haven't failed, I've found 10,000 ways that don't work - Thomas Edison
    Beware of the man who won't be bothered with details. - William Feather
    The greatest of faults is to be conscious of none. - Thomas Carlyle

  • Aren't Cocoa Memory Management Rules flawed?

    I understand the details of Cocoa memory management but I'm wondering what's the rationale behind the usage of autorelease with convenience constructors.
    The golden Cocoa rule is that factory methods send an autorelease message to objects prior to returning. But why is that? Why don't consider convenience constructors the same as alloc, newObject and the like?

    Well, that's even worse: if you create several throwaways with autorelease, you're essentially delaying their releasing to the release of the autorelease pool, i.e., by default, when the application quits, unless you provide your own autorelease pool. It sill doesn't make any sense to me.
    Stack based objects would have probably complicated the syntax of the language.

  • Release or Autorelease?

    Is there any noticeable benefit for using release instead of autorelease?
    Autorelease sends a release message at end of run loop, but release sends it immediately.
    Does anyone recommend that I use release whenever possible and try to avoid autorelease in general?

    Apple recommends this and I agree with them. From a design standpoint it keeps the memory management in your hands and makes you think about the tradeoffs rather than simply allocate and forget. The latter leads to bad practices that tend to show up as mysterious bugs later. It also helps to spread out the deallocation rather than have them happen all at once. It makes the memory profile of the app more consistent. I can see how that could have impacts on performance and whether or not Cocoa is forced to grow various caches, etc. It's sort of like eating your meals a couple times a day rather than waiting until the end of the week and eating them all at once =)

  • OSX inactive memory management problems

    On my 2010 Macbook Air 11" running OSX 10.8 Mountain Lion, I have run into some major issues with memory management. This problem persists across both my Mac machines and multiple generations of OSX. I have a 2007 2.2 Ghz Core 2 Duo Macbook Pro Running Lion (upgraded from Tiger) with 3 gb 667Mhz DDR2 RAM and my 2010 Air 1.4Ghz Core 2 Duo (Upgraded from Snow Leopard to Mountain Lion) with 2gb 1067mhz DDR3 RAM. On both machines, for some time now, during normal usage; especially web browsing using Chrome and Safari (respectively); the inactive RAM on both machines will grow to consume around 30% of all RAM and force time consuming page outs to the mass storage drives on both machines. The Pro has a slower hard drive and the problem is the worst here, the air has a much faster SSD. I have found myself constantly having a window of Activity Monitor up on at least one of my desktops watching my RAM usage, using terminal to purge ram upwards of 10 times an hour to prevent costly page outs, especially on the Pro. I know Apple claims that inactive RAM is essentially free RAM that is temporarily storing recently used information for ease of access later and that it's supposed to be released as free memory when needed, but this obviously is not happening. Right now on my air my swap file is over 650Mb and I've seen it top 2Gb before. The air is exponentially better than the Pro due to the faster SSD, but I do notice substantial UI lag and a massive drop in fluidity as soon as my meager 2Gb is full and I start paging. The Pro is another story entirely, the entire system will essentially become unusable, having to wait several seconds for mouse clicks to even register. That's why I upgraded the stock 2Gb of RAM it comes with to 3Gb hoping that a 150% increase in RAM would help, but it just prolonged the inevitable. I still end up paging out just as bad across both systems if un checked. Even when I keep a close eye on memory usage and purge often, I still end up paging out because I'm not vigilant enough.
    I have to limit my browsing to less than 5 tabs and keep my number of open programs less than 2 on both machines. My active and wired memory rarely seem to top 70%, meaning the rest gets taken by inactive, which isn't functioning as Apple claims. Even if my conclusions aobut what is happening under the hood are incorrect, something is going terribly wrong. I can't upgrade the RAM on my Air at all, and the RAM on my Pro is capped at 4Gb. I'm holding on upgrading because I don't think the excess hardware will solve this software memory problem. Whatever is happening is causing a serious drop in performance for me (yes I do know I have underpowered machines), but there has to be something I can do to speed performance. I've read about disabling the dynamic page file entirely, which just seems to crash the system when free memory is gone, and I've read about programs that claim to free memory. Those programs seem to work by taking a high priority in the process heigharchy of the OS and then proceeding to eat up large portions of RAM and releasing them as needed in an attempt to replicate the true intentions of inactive RAM, but I've heard of problems with this method as well. Does anyone have a viable solution? Monitoring my RAM usage myself and ensuring I don't end up paging out is costly, time consuming, annoying, and inefficient since I fail to catch the problem before I page if I get particularly busy. There is no other OS I've ever been acquainted with that has this problem, not any flavor of Linux, not even the dreaded windows. I seriously hope Apple can do something to manage this runaway memory problem. I'd like to be able to open more than 3 windows in Safari. I've had to purge 3 seperate times while writing this on my Air, and I now have 678 inactive memory, 741 inactive, 582 wired, and less than 14Mb free out of 2Gb with a growing swap at 680Mb. Each purge becomes less and less effective and the last one I did freed up only about 100Mb and it got eaten up again by inactive in less than 10 seconds. On my Air, the memory hog is Safari right now at 700Mb between the web content and flash player with only Facebook, youtube, and this Apple Supprt tab open. I have NO other applications running in the fore or background other than Activity Monitor and Terminal. On my Pro the memory hog is always kernel task, I use Chrome and Safari both. While the memory used by the browser does not usually take up the most substantial portion of the total used RAM out of any process, the more tabs I open, the more RAM I use. The browser is usually the second heaviest RAM hog to Kernel Task. So it seems that across the two machines there are two lsightly different manifestations of the same problem with the same results: massive performance drops and extremely annoying and costly page outs no matter the reason. I just want this problem to go away. I've used underpowered windows laptops that can open a dozen tabs in a heavier browser like IE or Firefox while using other programs like Word or Excel and more with no memory lag issues. There's no way in **** I could manage to open that many pages in a browser while using Pages and/or Numbers on either of my machines and expect reliable (swap free performance). This is just kind of sad in my opinion. Does anyone have a way to get my OSX machine running smooth so that I can remove the one thing that windows and Linux fan boys get the right to laugh at my Macs for?

    Hi Zephryl,
    I was actually able to get an initial response from Sun on this a few months ago. However, the Sun Swing team has not followed up on a resolution for this pervasive problem, even though they noticed the same problem when running a test applet I had created for them. Apparently, I.E. is not releasing memory from the heap.
    Below is a quote from a Sun rep. on this in an e-mail sent to me on Dec 4, 2002:
    "I suspected the leak is in the native code because the # of handles and GDI objects keep increasing but no obvious Java objects are left behind in the Java heap during page switch."
    So, until Sun and/or Microsoft work out a solution to this, anyone who uses I.E. 6 and applets for their UI seems to be in a lot of trouble.
    As a note, trying to invoke the Garbage Collector does not do anything, but generally a very small amount of memory will be released (like maybe 5-10% of the memory allocated for the applet).
    Cheers!
    Avi Gray
    Global Computer Enterprises

  • RE: (forte-users) memory management

    Brenda,
    When a partition starts, it reserves the MinimumAllocation. Within this
    memory space, objects are created and more and more of this memory is
    actually used. When objects are no longer referenced, they remain in memory
    and the space they occupy remains unusable.
    When the amount of free memory drops below a certain point, the garbage
    collector kicks in, which will free the space occopied by all objects that
    are no longer referenced.
    If garbage collecting can't free enough memory to hold the additional data
    loaded into memory, then the partition will request another block of memory,
    equal to the IncrementAllocation size. The partition will try to stay within
    this new boundary by garbage collecting everytime the available part of this
    memory drops below a certain point. If the partition can't free enough
    memory, it will again request another block of memory.
    This process repeats itself until the partition reaches MaximumAllocation.
    If that amount of memory still isn't enough, then the partition crashes.
    Instrument ActivePages shows the memory reserved by the partition.
    AllocatedPages shows the part of that memory actually used.
    AvailablePages shows the part ot that memory which is free.
    Note that once memory is requested from the operating system, it's never
    released again. Within this memory owned by the partition, the part actually
    used will always be smaller. But this part will increase steadily, until the
    garbage collecter is started and a part of it is freed again.
    There are some settings that determine when the garbage collector is
    started, but I'm not sure which ones they are.
    The garbage collector can be started from TOOL using
    "task.Part.OperatingSystem.RecoverMemory()", but I'm not sure if that will
    always actually start the garbage collector.
    If you track AllocatedPages of a partition, it's always growing, even if the
    partition isn't doing anything. I don't know why.
    If you add AllocatedPages and AvailablePages, you shoud get the value of
    ActivePages, but you won't. You always get a lower number and sometimes even
    considerably lower. I don't know why.
    Pascal Rottier
    Atos Origin Nederland (BAS/West End User Computing)
    Tel. +31 (0)10-2661223
    Fax. +31 (0)10-2661199
    E-mail: Pascal.Rottiernl.origin-it.com
    ++++++++++++++++++++++++++++
    Philip Morris (Afd. MIS)
    Tel. +31 (0)164-295149
    Fax. +31 (0)164-294444
    E-mail: Rottier.Pascalpmintl.ch
    -----Original Message-----
    From: Brenda Cumming [mailto:brenda_cummingtranscanada.com]
    Sent: Tuesday, January 23, 2001 6:40 PM
    To: Forte User group
    Subject: (forte-users) memory management
    I have been reading up on memory management and the
    OperatingSystemAgent, and could use some clarification...
    When a partition is brought online, is the ActivePages value set to the
    MinimumAllocation value, and expanded as required?
    And what is the difference between the ExpandAtPercent and
    ContractAtPercent functions?
    Thanks in advance,
    Brenda
    For the archives, go to: http://lists.xpedior.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com

    The Forte runtime is millions of lines of compiled C++ code, packaged into
    shared libraries (DLL's) which are a number of megabytes in size. The
    space is taken by the application binary, plus the loaded DLL's, plus
    whatever the current size of garbage collected memory is.
    Forte allocates a garbage-collected heap that must be bigger than the size
    of the allocated objects. So if you start with an 8MB heap, you will always
    have at least 8MB allocated, no matter what objects you actually
    instantiate. See "Memory Issues" in the Forte System Management Guide.
    -tdc
    Tom Childers
    iPlanet Integration Server Engineering
    At 10:37 PM 6/11/01 +0200, [email protected] wrote:
    Hi all,
    I was wondering if anyone had any experience in deploying clients on NT
    concerning
    the memory use of these client apps.
    What is the influence of the various compiler options (optimum
    performance, memory use etc)?
    We seem to see a lot of the memory is taken by the Forte client apps (seen
    in the Task Manager
    of NT) in respect to the other native Window apps. For example an
    executable of approx 4Mb takes up to
    15Mb of memory. When I look at the objects retained in memory after
    garbage collection, these are about
    2Mb. Where do the other Mb's come from?

  • LR 2.3RC - Memory not released from Develop

    I am running 2.3RC under Windows XP. It's going fine but it still has a memory issue that I observed under 2.2.
    After going from Library Grid to Develop, then going back to Grid without doing any actions in Develop (actually, it doesn't matter whether you do anything or not), I see approximately an extra 180M in the VM size in Windows Task Manager. If I then go into Print the VM size stays about the same - about 180M bigger than it should be.
    However, if instead, once I return to Grid from Develop, I then use the arrow key and select another image, the memory is released. I can then go back to the original image and the memory does not increase. Then I can go to Print and, once again, the memory does not increase (some minor change - in fact, on my machine, it goes down!).
    Looks like as long as the original image is selected, memory from Develop is not being released. As I said at the outset, this is not new in 2.3RC - it also happened in 2.2.
    Also - no local adjustments were or have been made to the image in question.
    Anyone else see this on their machines?
    Selby Shanly

    Ian and Simon - you are correct, it is not a leak. Please note that is 180M - not 180K.
    Of course, as users, we simply don't know whether or not it is cached information that actually gets reused, or just a mistake.
    The Print Spooler under XP takes a good chunk of memory - why fight for it with LR? What about Photoshop? Often the next thing I do after Develop is go to PS to do soft proofing. PS could use that memory.
    The question to Adobe is whether or not this is an oversight. If it is then they alone are in the position to evaluate the risks of changing the code - it might be utterly trivial. If it is deliberate and provides efficiencies then at least it would be interesting to know!
    Even with the size of current machines, 180M of memory (YMMV) is still not something to use up lightly for no benefit. And for users who are tight on memory and at the knee of the performance curve, it might make a noticable difference.
    But all of this is speculation on my part - let's see what Adobe says.
    I do appeciate the comments. Thanks.
    Selby

  • How does object memory management works?

    Hi all,
    I'm having a lot of problems with memory which seems not to be released when using objects (on Oracle 9i 9.0.1.1.1). I've prepared the following test:
    create type t_test as object (
    id number,
    member function FunctTest(TBL IN CHAR, expand IN CHAR) return varchar2
    ) not final;
    create or replace type body t_test as
    MEMBER FUNCTION FunctTest(TBL IN CHAR, expand IN CHAR) RETURN varchar2 IS
    BEGIN
    return NULL;
    END FunctTest;
    end;
    create or replace function FunctTest2(TBL IN CHAR, expand IN CHAR) RETURN varchar2 IS
    BEGIN
    return NULL;
    END FunctTest2;
    create table tab_test of t_test;
    insert into tab_test values(1);
    commit;
    As you can see, I create a simple type with a member function, and a schema function who does the same (nothing, in this case). Then I call the two functions with the following PL/SQL blocks:
    declare i integer;
    t varchar2(4000);
    ob t_test;
    begin
    select value(a) into ob from tab_test a where a.id=1;
    for i in 1..5000 loop
    select ob.FunctTest('A','S') into t from dual;
    end loop;
    end;
    declare i integer;
    t varchar2(4000);
    begin
    for i in 1..5000 loop
    select FunctTest2('A','S') into t from dual;
    end loop;
    end;
    If you run these blocks with Task Manager opened (I use W2000) on server console, you can see how memory usage grows very fast with the first block, and how it doesn't change with the second one.
    The memory isn't released till the session is alive.
    I'm trying to develop an object application, but these memory leaks are making me crazy.
    Geoff, does release 2 solve some of these problems?
    In particular, please, do I need to free by myself temporary objects (these ones referenced in PL/SQL blocks)? In which way? I haven't found anything about object memory management in documentation...
    As always,
    Thanks for any support to everybody.
    Andrea Arilotta
    [email protected]

    Andrea,
    Do you have an Oracle Support customer ID? If you can log a TAR on http://metalink.oracle.com with your customer id, someone can take a closer look at this problem.
    Regards,
    Geoff
    Hi all,
    I'm having a lot of problems with memory which seems not to be released when using objects (on Oracle 9i 9.0.1.1.1). I've prepared the following test:
    create type t_test as object (
    id number,
    member function FunctTest(TBL IN CHAR, expand IN CHAR) return varchar2
    ) not final;
    create or replace type body t_test as
    MEMBER FUNCTION FunctTest(TBL IN CHAR, expand IN CHAR) RETURN varchar2 IS
    BEGIN
    return NULL;
    END FunctTest;
    end;
    create or replace function FunctTest2(TBL IN CHAR, expand IN CHAR) RETURN varchar2 IS
    BEGIN
    return NULL;
    END FunctTest2;
    create table tab_test of t_test;
    insert into tab_test values(1);
    commit;
    As you can see, I create a simple type with a member function, and a schema function who does the same (nothing, in this case). Then I call the two functions with the following PL/SQL blocks:
    declare i integer;
    t varchar2(4000);
    ob t_test;
    begin
    select value(a) into ob from tab_test a where a.id=1;
    for i in 1..5000 loop
    select ob.FunctTest('A','S') into t from dual;
    end loop;
    end;
    declare i integer;
    t varchar2(4000);
    begin
    for i in 1..5000 loop
    select FunctTest2('A','S') into t from dual;
    end loop;
    end;
    If you run these blocks with Task Manager opened (I use W2000) on server console, you can see how memory usage grows very fast with the first block, and how it doesn't change with the second one.
    The memory isn't released till the session is alive.
    I'm trying to develop an object application, but these memory leaks are making me crazy.
    Geoff, does release 2 solve some of these problems?
    In particular, please, do I need to free by myself temporary objects (these ones referenced in PL/SQL blocks)? In which way? I haven't found anything about object memory management in documentation...
    As always,
    Thanks for any support to everybody.
    Andrea Arilotta
    [email protected]

  • Difference between nio-file-manager  and nio-memory-manager

    Hi,
    what's the difference between nio-file-manager and nio-memory-manager? The documentation doesn't really discuss the differences as far as I know. They both use nio to store memory-mapped files don't they? What are the advantages/disadvantages of both?
    When to choose the first one and when the second when storing a large amount of data? Can both be used to query data with the Filter API? Are there size limits on both?
    Best regards
    Jan

    Hi Jan,
    The difference is that one uses a memory mapped file and one uses direct nio memory (as part of the memory allocated by the JVM process) to store the data. Both allow storing cache data off heap making it possible to store more data with a single cache node (JVM) without long GC pauses.
    If you are using a 32 bit JVM, the JVM process will be limited to a total of ~3GB on Windows and 4GB on Linux/Solaris. This includes heap and off heap memory allocation.
    Regarding the size limitations for the nio-file manager Please see the following doc for more information.
    With the release of 3.5 there is now the idea of a Partitioned backing map which helps create larger (up to 8GB of capacity) for nio storage. Please refer to the following doc.
    Both can be used to query data but it should be noted that the indexes will be stored in heap.
    hth,
    -Dave

  • HT3258 dynamic memory manager

    Does Apple fix the problems with the dynamic memory manager in Mountain Lion?

    After more tests I can say that this memory consumption
    disappear with a release version of the swf executed directly by
    the browser.

  • Memory Management in LabView / DLL

    Hi all,
    I have a problem concerning the memory management of LabView. If my data is bigger than 1 GB, LabView crashes with an error message "Out of Memory" (As LabView passes Data only by value and not by reference, 1 GB can be easily achieved). My idee is to divide the data structure into smaller structures and stream them from Hard Disk as they are needed. To do so, i have to get access to a DLL which reads this data from disk. As a hard disk is very slow in comparison to RAM, the LabView program gets very slow.
    Another approach was to allocate memory in the DLL and pass the pointer back to LabView...like creating a Ramdisk and reading the data from this disk. But memory is allocated in the context of Labview...so LabView crashes because the memory was corrupted by C++. Allocating memory with LabView-h-Files included doesnt help because memory is still allocated in the LabView context. So does anybody know if it's possible to allocate memory in a C++-DLL outside the LabView context, so that i can read my Data with a DLL by passing the pointer to this DLL by LabView? It should work the following way:
    -Start LabView program--> allocate an amount of memory for the data, get pointer back to labview
    -Work with the program and the data. If some data is needed, a DLL reads from the memory space the pointer is pointing at
    -Stop LabView program-->Memory is freed
    Remember: The data structure should be used like a global variable in a DLL or like a ramdisk!
    Hope you can understand my problem
    Thanks in advance
    Christian
    THINK G!! ;-)
    Using LabView 2010 and 2011 on Mac and Win
    Programming in Microsoft Visual C++ (Win), XCode (Mac)

    If you have multiple subvis grabbing 200MB each you might try using the "Request Deallocation" function so that once a vi is done processing it releases the memory.
    LabVIEW Help: "When a top-level VI calls a subVI, LabVIEW allocates a data space
    of memory in which that subVI runs. When the subVI finishes running, LabVIEW
    usually does not deallocate the data space until the top-level VI finishes
    running or until the entire application stops, which can result in out-of-memory
    conditions and degradation of performance. Use this function to deallocate the
    data space immediately after the VI completes execution."
    Programming >> Application Control >> Memory Control >> Request Deallocation
    I think it first appeared in LabVIEW 7.1.
    Message Edited by Troy K on 07-14-2008 09:36 AM
    Troy
    CLDEach snowflake in an avalanche pleads not guilty. - Stanislaw J. Lec
    I haven't failed, I've found 10,000 ways that don't work - Thomas Edison
    Beware of the man who won't be bothered with details. - William Feather
    The greatest of faults is to be conscious of none. - Thomas Carlyle

  • Memory management - what is best way?

    Hi All,
    I was wondering what is the best way of doing certain things in SBO especially with regards to memory usage and proper memory management. If I have an edit text which I want to set a value in what would be the best way?
    Option 1:
            Dim oEdit As SAPbouiCOM.EditText
            oEdit = oForm.Items.Item("myItem").Specific
            oEdit.Value = "Hello"
            System.Runtime.InteropServices.Marshal.ReleaseComObject(oEdit)
    Option 2:
            oForm.Items.Item("myItem").Specific.Value = "Hello"
    In the first option I declare a variable, set its value and free it. In the second option I just set the value without creating an instance of the object. Does the second option use the same amount of memory as the first (because it also refers to the same object) and it doesn't free it, or what is best?
    I have tried to test it, but couldn't get a definate answer.
    Your input is appreciated!
    Adele

    option 1 is to much of a hassle.  You should release the objects only when your using business objects, specially in row records in matrixes and when using recordsets.  Specially recordsets.
    Regards,
    WB

  • Memory management count

    Hello all,
    I have a general inquiry on keeping the memory count in regards to memory management. Suppose my set routine is this (which I believe is the general set routine, save for checking that the new input does not equal the current value):
    -(void)setVariable:(id)newValue{
    [[variable release]];
    [[newValue retain]];
    Variable = newValue;
    1. Assuming 'newValue' has not been retained or allocated elsewhere, it's count here is 1. Is that right?
    2. Is the count of 'variable' also 1? We didn't actually retain 'variable'. But what it's pointing to is retained. I am unsure how the count is kept. Who get's the extra 1? 'variable' or 'newValue'?
    Message was edited by: rpstro02
    Message was edited by: rpstro02

    Keep in mind that the variables you're dealing with here are pointers to objects. And that it's the actual objects that have a retainCount, not the pointers.
    So when you do:
    [newValue retain];
    ... it's whatever object newValue is pointing to that gets an incremented retainCount... not the newValue pointer itself.
    Then when you do:
    variable = newValue;
    ... now you've just made your "variable" pointer point to the _same object_ that newValue is pointing to. There's only one retainCount involved. So there is not an "extra 1" if I'm understanding that part of your question correctly.
    Steve

  • IPhone: Memory Management / Tracking Tools

    I am new to Mac/iPhone programming but have 20+ years in Windows. I am not familiar with the tools but MS Dev Studio will show memory leaks as the app shuts down. Is there a similar switch to turn on for xcode? I am having trouble with the gestalt of memory management on this platform. For example, I know this is bad code style but is there a leak here?
    myLabel.text = [@"Hello, World. " stringByAppendingString: myTextField.text];
    Thanks,
    Todd

    I found section four of this document incredibly useful.
    Broadly speaking, if you create an object using "alloc" you need to manually clean up afterwards, otherwise it will be autoreleased and you won't get a memory leak.
    XCode comes with Instruments which allows you to track down leaks (among other things).
    Cheers,
    --> Stephen

Maybe you are looking for

  • Issues with External Hard Drives

    I hope this is the right forum for this one - please give me a steer if not! I've also posted it in 'Dock and Finder', but this forum seems equally appropriate, if not more so. I'm getting repeated issues with External Hard Drives, including ones tha

  • Storing Multiple Essbase Backups

    Hello, We currently run a nightly backup using the MaxL script below. Due to a change in business practices, we now need to save mulitple days worth of backups instead of writing over the previous night's backup, as we do in this script. Does anyone

  • Deactivate software from old pc (that has been formatted)

    I can't use my serial number; I get this message: "The serial number (my #) is already in use by the maximum allowed computers. You need to deactivate another computer within 30 days to use this product." It turns out that the IT guys formatted my ol

  • Workshop 8.1 detect source code changes

    Hi, I'm working on a web service application using Workshop 8.1sp4. When I run my web application in debug mode, the server will only detect Java source code changes within the webapps (WEB-INF/src). If I move the source code outside the webapp and i

  • Downgrade database

    Hi I have a 10.2.0.3 and need to downgrade to 10.2.0.2, the compatible parameter is 10.2.0.3. what's the best solution? Tks