memory leak in script??

Ask a Question related to ASP Components, Design and Development.

  1. #1

    Default memory leak in script??

    Hey eb
    can this be the reason for huge memory expansion ?
    Doesn't this script free memory of the object it had created?

    sub createCOMobject()
    set obj1 = createObject("object1")
    dim flag = 1
    useObject flag,obj1
    end sub
    ----------------------------------
    sub useObject (flag, byRef obj1)
    ....
    set obj1 = Nothing
    end sub

    Thanks for your attention
    Rea

    Rea Guest

  2. Similar Questions and Discussions

    1. #39438 [NEW]: Memory leak PHP Fatal error: Out of memory
      From: nikolas dot hagelstein at gmail dot com Operating system: NETBSD 3.0.1 AMD64 PHP version: 5.2.0 PHP Bug Type: ...
    2. memory problem/memory leak
      Hi I have a problem with shockwave player running in Internet Explorer. My program consists of a controller movie which loads in content files in...
    3. Memory consumption of Ruby/mod_ruby combo on Apache [memory leak]
      > I don't think so - I think all the modules are loaded when Apache is It didn't have anything to do with IfModules or even Apache. I had a...
    4. AIX 4.3.3 leak memory
      I don't understand why, I have a program which leak memory on AIX 4.3.3 and not on others (AIX 4.3.3 or AIX 4.2 or Linux or SUN...). I try to use...
    5. Is this a memory leak???
      Hi Nicholas So is there a way to release the file cache ?. We did another test using a AIX 4.3 box, to allocate some memory then read a large...
  3. #2

    Default Re: memory leak in script??


    "Rea" <Rea@discussions.microsoft.com> wrote in message
    news:953AB6C1-FF00-45ED-88B5-9BAF67CBF536@microsoft.com...
    > Hey eb
    > can this be the reason for huge memory expansion ?
    > Doesn't this script free memory of the object it had created?
    >
    > sub createCOMobject()
    > set obj1 = createObject("object1")
    > dim flag = 1
    > useObject flag,obj1
    > end sub
    > ----------------------------------
    > sub useObject (flag, byRef obj1)
    > ...
    > set obj1 = Nothing
    > end sub
    >
    > Thanks for your attention
    > Rea
    >
    Setting an object variable to nothing does not free memory.

    Assigning a new value (whatever it is not just nothing) to variable will
    cause the release method of the any currently held reference to be called
    before the reference is replaced by the new value.

    Calling release on an interface reference (commonly known as an object
    variable) causes the object to decrement an internally held count of the
    number of references that have been made. When this count reaches zero then
    it is the object's responsibility to deallocate any memory or other
    resources it may be holding.

    obj1 is passed byRef (the default mode in VBScript BTW) so the assigning of
    Nothing to obj1 is applied to the variable of the same name in the
    createCOMobject procedure. Since this is the only reference being held the
    internal reference count of the object drops to zero and the object should
    destroy itself at this point.

    However without the line assigning nothing to the obj1 variable the obj1
    variable is destroyed when the procedure createCOMobject returns, at this
    point any reference currently held in obj1 has it's release method called.
    Hence in this case the assignment of nothing is superflous.

    HTH,

    Anthony.



    Anthony Jones Guest

  4. #3

    Default Re: memory leak in script??

    Thanks Anthony
    I see your point.
    But according to what you say, memory
    should be released at the end of my script's execution..
    while it clearly does not.
    I follow memory consumption of my application,
    and each time i run this script i see a growth in totall memory consumed by
    it.


    "Anthony Jones" wrote:
    >
    > "Rea" <Rea@discussions.microsoft.com> wrote in message
    > news:953AB6C1-FF00-45ED-88B5-9BAF67CBF536@microsoft.com...
    > > Hey eb
    > > can this be the reason for huge memory expansion ?
    > > Doesn't this script free memory of the object it had created?
    > >
    > > sub createCOMobject()
    > > set obj1 = createObject("object1")
    > > dim flag = 1
    > > useObject flag,obj1
    > > end sub
    > > ----------------------------------
    > > sub useObject (flag, byRef obj1)
    > > ...
    > > set obj1 = Nothing
    > > end sub
    > >
    > > Thanks for your attention
    > > Rea
    > >
    >
    > Setting an object variable to nothing does not free memory.
    >
    > Assigning a new value (whatever it is not just nothing) to variable will
    > cause the release method of the any currently held reference to be called
    > before the reference is replaced by the new value.
    >
    > Calling release on an interface reference (commonly known as an object
    > variable) causes the object to decrement an internally held count of the
    > number of references that have been made. When this count reaches zero then
    > it is the object's responsibility to deallocate any memory or other
    > resources it may be holding.
    >
    > obj1 is passed byRef (the default mode in VBScript BTW) so the assigning of
    > Nothing to obj1 is applied to the variable of the same name in the
    > createCOMobject procedure. Since this is the only reference being held the
    > internal reference count of the object drops to zero and the object should
    > destroy itself at this point.
    >
    > However without the line assigning nothing to the obj1 variable the obj1
    > variable is destroyed when the procedure createCOMobject returns, at this
    > point any reference currently held in obj1 has it's release method called.
    > Hence in this case the assignment of nothing is superflous.
    >
    > HTH,
    >
    > Anthony.
    >
    >
    >
    >
    Rea Guest

  5. #4

    Default Re: memory leak in script??


    "Rea" <Rea@discussions.microsoft.com> wrote in message
    news:95D11CF1-AA93-45D4-9AD9-9A7E668B709D@microsoft.com...
    > Thanks Anthony
    > I see your point.
    > But according to what you say, memory
    > should be released at the end of my script's execution..
    > while it clearly does not.
    > I follow memory consumption of my application,
    > and each time i run this script i see a growth in totall memory consumed
    by
    > it.
    Then the fault is either with the object itself what is it?
    Or code that you haven't yet shown us. Show us more code.
    >
    >
    > "Anthony Jones" wrote:
    >
    > >
    > > "Rea" <Rea@discussions.microsoft.com> wrote in message
    > > news:953AB6C1-FF00-45ED-88B5-9BAF67CBF536@microsoft.com...
    > > > Hey eb
    > > > can this be the reason for huge memory expansion ?
    > > > Doesn't this script free memory of the object it had created?
    > > >
    > > > sub createCOMobject()
    > > > set obj1 = createObject("object1")
    > > > dim flag = 1
    > > > useObject flag,obj1
    > > > end sub
    > > > ----------------------------------
    > > > sub useObject (flag, byRef obj1)
    > > > ...
    > > > set obj1 = Nothing
    > > > end sub
    > > >
    > > > Thanks for your attention
    > > > Rea
    > > >
    > >
    > > Setting an object variable to nothing does not free memory.
    > >
    > > Assigning a new value (whatever it is not just nothing) to variable will
    > > cause the release method of the any currently held reference to be
    called
    > > before the reference is replaced by the new value.
    > >
    > > Calling release on an interface reference (commonly known as an object
    > > variable) causes the object to decrement an internally held count of the
    > > number of references that have been made. When this count reaches zero
    then
    > > it is the object's responsibility to deallocate any memory or other
    > > resources it may be holding.
    > >
    > > obj1 is passed byRef (the default mode in VBScript BTW) so the assigning
    of
    > > Nothing to obj1 is applied to the variable of the same name in the
    > > createCOMobject procedure. Since this is the only reference being held
    the
    > > internal reference count of the object drops to zero and the object
    should
    > > destroy itself at this point.
    > >
    > > However without the line assigning nothing to the obj1 variable the obj1
    > > variable is destroyed when the procedure createCOMobject returns, at
    this
    > > point any reference currently held in obj1 has it's release method
    called.
    > > Hence in this case the assignment of nothing is superflous.
    > >
    > > HTH,
    > >
    > > Anthony.
    > >
    > >
    > >
    > >

    Anthony Jones Guest

Posting Permissions

  • You may not post new threads
  • You may 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