Professional Web Applications Themes

memory leak in script?? - ASP Components

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...

  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. #2

    Default Re: memory leak in script??


    "Rea" <Readiscussions.microsoft.com> wrote in message
    news:953AB6C1-FF00-45ED-88B5-9BAF67CBF536microsoft.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

  3. #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" <Readiscussions.microsoft.com> wrote in message
    > news:953AB6C1-FF00-45ED-88B5-9BAF67CBF536microsoft.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

  4. #4

    Default Re: memory leak in script??


    "Rea" <Readiscussions.microsoft.com> wrote in message
    news:95D11CF1-AA93-45D4-9AD9-9A7E668B709Dmicrosoft.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" <Readiscussions.microsoft.com> wrote in message
    > > news:953AB6C1-FF00-45ED-88B5-9BAF67CBF536microsoft.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

Similar Threads

  1. #39438 [NEW]: Memory leak PHP Fatal error: Out of memory
    By nikolas dot hagelstein at gmail dot com in forum PHP Bugs
    Replies: 11
    Last Post: December 1st, 08:08 PM
  2. SQL Memory Leak
    By in forum Coldfusion Server Administration
    Replies: 1
    Last Post: September 6th, 04:55 PM
  3. memory problem/memory leak
    By Tron Juan Del Marco webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 1
    Last Post: January 20th, 06:02 PM
  4. big memory leak
    By nikokupa webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 0
    Last Post: December 5th, 10:53 AM
  5. Memory consumption of Ruby/mod_ruby combo on Apache [memory leak]
    By David Heinemeier Hansson in forum Ruby
    Replies: 4
    Last Post: September 10th, 01:58 AM

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