clear all problem.

  • Hey all,

    I have a program that is like a glorified logging utility that highlights
    and filters incoming logs, and keeps track of a set amount of logs.

    the problem is that my so called 'restart' command which releases all my
    major data structures and then re-declares them doesnt work in the memory
    sense.

    for instance, if the code was using 120mb real memory (seen via top command
    in terminal), then releasing and reallocating does not cause the program to
    occupy any less memory.  I dont expect it to occupy as much memory when its
    first started, but i don't know why the memory requirements don't go down at
    all.

    This is causing a problem in the long term stability of my app and i'm not
    sure what i can do to fix it.

    any help will be appreciated.

    *eg code:*

    clear:(id)sender
    {
        [array release]    //stores logs that the logger displays in its GUI
        ....
        array = [[NSMutableArray alloc]init];  //a new array that will store
    logs
        .....
    }
  • On Nov 25, 2007, at 10:28 PM, Erfan Aleemullah wrote:

    > for instance, if the code was using 120mb real memory (seen via top
    > command
    > in terminal), then releasing and reallocating does not cause the
    > program to
    > occupy any less memory.

    What column in the top report were you observing?  "120mb real memory"
    doesn't say whether you were paying attention to RSIZE, RPRVT, etc.

    > I dont expect it to occupy as much memory when its
    > first started, but i don't know why the memory requirements don't go
    > down at
    > all.

    That depends entirely on what you mean by "memory requirements."
    Address space, once granted to an application, is very rarely handed
    back to the operating system.  Thus if you look at the wrong values,
    you may perceive your "memory requirements" to not go down even though
    the amount of memory in actual use may be reduced.  It's critical to
    know exactly what you're measuring and how you're measuring it.

    > This is causing a problem in the long term stability of my app and
    > i'm not
    > sure what i can do to fix it.
    >
    > any help will be appreciated.
    >
    > *eg code:*
    >
    > clear:(id)sender
    > {
    > [array release]    //stores logs that the logger displays in its
    > GUI
    > ....
    > array = [[NSMutableArray alloc]init];  //a new array that will
    > store
    > logs
    > .....
    > }

    Is "array" a property of your controller that a table view is bound
    to?  If so, see my recent response in the "NSArrayController
    frustration" thread for why the above is not something you want to do.

      -- Chris
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today