Professional Web Applications Themes

free() and memory usage - UNIX Programming

Hi all, On a linux box, there are several instances of my application running for different purposes, testing/QA... I also running my own test instance "myapp" on it. During working hours, the "size" in top of myapp is easily grow and seems no uplimit; after working hour, with same input, the size will remain around a certain amount, means: on working hours(myapp was a little slower): the test client sent 100 requests to myapp, the "size" would grew to 26mb. after: the test client sent exactly 100 same content(ensure same processing routains) request to myapp, size aroud 16mb. No memleak ...

  1. #1

    Default free() and memory usage

    Hi all,

    On a linux box, there are several instances of my application running for
    different purposes, testing/QA... I also running my own test instance
    "myapp" on it. During working hours, the "size" in top of myapp is easily
    grow and seems no uplimit; after working hour, with same input, the size
    will remain around a certain amount, means:
    on working hours(myapp was a little slower):
    the test client sent 100 requests to myapp, the "size" would grew to 26mb.
    after:
    the test client sent exactly 100 same content(ensure same processing
    routains) request to myapp, size aroud 16mb.

    No memleak when checked with valgrind and mtrace() in above 16mb case (the
    26mb case needs the working day though).

    Here goes my questions:
    1) the size of top constantly grows means a leak?
    2) if free() of glibc doesn't (always?) return the memory to OS, is this
    behave can be affected by process' current running env or time(how long the
    process holds the resource) related?
    3) what are other possible reasons for above different "size" with same
    inputs/outputs to a process?

    Thanks in advance


    -sean


    concern Guest

  2. #2

    Default Re: free() and memory usage


    "concern" <net> writes:
     

    Lots of applications have a memory use patterns where
    they grow over time, but eventually plateau at some
    constant long-term level.

    First, note that free() does not return memory to the
    OS, only marks that block as free in your process's
    heap. Over the long term, free areas in your heap
    become intermingled with areas that are in use,
    which limits the ability of malloc() to merge small
    free blocks into larger blocks. Over time, the heap
    becomes more "fragmented", and therefore larger,
    until an equilibrium is reached.

    Applications that have leaks never reach equilibrium,
    but continue to grow indefinitely. Note however that
    not every program that grows indefinitely has leaks.

    For example, if you allocate memory and store pointers
    to those blocks in a list or table, and fail to free
    them after they are no longer needed, tools like Purify
    (and, I assume, valgrind) won't report them as leaks,
    since to all appearances they are still in use.

    In rarer cases, a set of memory blocks that contain
    circular chains of reference to one another will also
    escape detection, since each block will appear to be
    used by the other.

    -SEan


    Sean Guest

  3. #3

    Default Re: free() and memory usage

    in comp.unix.programmer i read:
     

    not necessarily.
     

    gnu libc only returns memory to the o/s when there is a sufficiently large
    block. see the doentation for more information.
     

    something is different it would seem. find those differences.

    --
    a signature
    those Guest

Similar Threads

  1. COM memory and CPU usage
    By rio in forum ASP Components
    Replies: 1
    Last Post: October 11th, 06:19 AM
  2. Too Much Memory Usage
    By dave milbut in forum Adobe Photoshop 7, CS, CS2 & CS3
    Replies: 9
    Last Post: August 27th, 10:27 PM
  3. CPU and Memory usage
    By Jesper Nordestgaard in forum AIX
    Replies: 3
    Last Post: July 29th, 05:33 PM
  4. memory usage
    By martin sanabia in forum Windows XP/2000/ME
    Replies: 13
    Last Post: July 22nd, 08:59 PM
  5. PS Memory Usage
    By Ray in forum Adobe Photoshop Elements
    Replies: 9
    Last Post: June 29th, 04:37 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139