Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Wierd resource disposal?

Wierd resource disposal?

Scheduled Pinned Locked Moved C#
helpcsharpperformancequestionlearning
11 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    asator
    wrote on last edited by
    #1

    Hi, i have written a program and i am experiencing a wierd problem with the memory usage... once i open the program it will keep on draing more memory, it will never stop :D if i minimize the program the memory will dispose(?) and the program will drop to about 2-5mb and start growing again... is it a bug in .net or did i not read something correctly? I thank everyone for intrest in the problem

    S A R 4 Replies Last reply
    0
    • A asator

      Hi, i have written a program and i am experiencing a wierd problem with the memory usage... once i open the program it will keep on draing more memory, it will never stop :D if i minimize the program the memory will dispose(?) and the program will drop to about 2-5mb and start growing again... is it a bug in .net or did i not read something correctly? I thank everyone for intrest in the problem

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      asator wrote:

      is it a bug in .net or did i not read something correctly?

      Impossible to say without knowing what your program does.


      "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

      www.troschuetz.de

      A 1 Reply Last reply
      0
      • S Stefan Troschuetz

        asator wrote:

        is it a bug in .net or did i not read something correctly?

        Impossible to say without knowing what your program does.


        "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

        www.troschuetz.de

        A Offline
        A Offline
        asator
        wrote on last edited by
        #3

        well it does make alot of httpwebrequests, operate on alot of strings(retreive data from the response, alot of string.substring and string.indexof calls) i think it has something to do with one of these... ps. i noticed in a memory profiler that the program has 112k string instances...wtf?

        S 1 Reply Last reply
        0
        • A asator

          Hi, i have written a program and i am experiencing a wierd problem with the memory usage... once i open the program it will keep on draing more memory, it will never stop :D if i minimize the program the memory will dispose(?) and the program will drop to about 2-5mb and start growing again... is it a bug in .net or did i not read something correctly? I thank everyone for intrest in the problem

          A Offline
          A Offline
          asator
          wrote on last edited by
          #4

          i would also like to ask another question, can i somehow 'call' the Form.Minimize method without the 'visual' efects? :D i mean something like simulating the minimze method in order to free the memory? maybe someone knows what is called when the form is minimzed?

          1 Reply Last reply
          0
          • A asator

            Hi, i have written a program and i am experiencing a wierd problem with the memory usage... once i open the program it will keep on draing more memory, it will never stop :D if i minimize the program the memory will dispose(?) and the program will drop to about 2-5mb and start growing again... is it a bug in .net or did i not read something correctly? I thank everyone for intrest in the problem

            R Offline
            R Offline
            Ranjan Banerji
            wrote on last edited by
            #5

            asator wrote:

            once i open the program it will keep on draing more memory, it will never stop

            So if you do not minimize do you get a Sytem Out Of Memory Exception?

            My pointless rants meragussa.blogspot.com[^]

            A 1 Reply Last reply
            0
            • R Ranjan Banerji

              asator wrote:

              once i open the program it will keep on draing more memory, it will never stop

              So if you do not minimize do you get a Sytem Out Of Memory Exception?

              My pointless rants meragussa.blogspot.com[^]

              A Offline
              A Offline
              asator
              wrote on last edited by
              #6

              i myself didnt get to the no memory state but alot of users(esspecially the ones with low amount of memory, 128mb and below), they report that after a long period of time, usally over 24h their system 'hangs', 'freezes', so no - there is no exception thrown

              1 Reply Last reply
              0
              • A asator

                well it does make alot of httpwebrequests, operate on alot of strings(retreive data from the response, alot of string.substring and string.indexof calls) i think it has something to do with one of these... ps. i noticed in a memory profiler that the program has 112k string instances...wtf?

                S Offline
                S Offline
                Stefan Troschuetz
                wrote on last edited by
                #7

                Try closing the HttpWebResponses after you finished retrieval of data and try to minimize use of SubString as each return value is a new string object. Maybe you can use regular expression to be more efficient but it depends on what exactly you are doing.


                "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

                www.troschuetz.de

                A 1 Reply Last reply
                0
                • S Stefan Troschuetz

                  Try closing the HttpWebResponses after you finished retrieval of data and try to minimize use of SubString as each return value is a new string object. Maybe you can use regular expression to be more efficient but it depends on what exactly you are doing.


                  "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

                  www.troschuetz.de

                  A Offline
                  A Offline
                  asator
                  wrote on last edited by
                  #8

                  1. what do you mean by closing? 2. here is an example of what i am doing:

                  strX[i] = strX[i].Substring(strX[i].IndexOf("href="));
                  strX[i] = strX[i].Substring(strX[i].IndexOf("ht"));
                  strX[i] = strX[i].Replace("amp;", "");

                  there is much more of this and this is in a for loop with about 100 loops... so now i know how i got to 112k string objects... so can i do what i am doing in a better way?(i mean the substring issue)

                  S 1 Reply Last reply
                  0
                  • A asator

                    1. what do you mean by closing? 2. here is an example of what i am doing:

                    strX[i] = strX[i].Substring(strX[i].IndexOf("href="));
                    strX[i] = strX[i].Substring(strX[i].IndexOf("ht"));
                    strX[i] = strX[i].Replace("amp;", "");

                    there is much more of this and this is in a for loop with about 100 loops... so now i know how i got to 112k string objects... so can i do what i am doing in a better way?(i mean the substring issue)

                    S Offline
                    S Offline
                    Stefan Troschuetz
                    wrote on last edited by
                    #9

                    1. By closing I mean calling its Close method[^]. 2. As said before you may be able to get rid of some SubString calls by using regular expressions.


                    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

                    www.troschuetz.de

                    A 1 Reply Last reply
                    0
                    • S Stefan Troschuetz

                      1. By closing I mean calling its Close method[^]. 2. As said before you may be able to get rid of some SubString calls by using regular expressions.


                      "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

                      www.troschuetz.de

                      A Offline
                      A Offline
                      asator
                      wrote on last edited by
                      #10

                      1. ok so all my httpwebresponses close 2. what do you mean by regular expresions? 3. thank you for your help :)

                      1 Reply Last reply
                      0
                      • A asator

                        Hi, i have written a program and i am experiencing a wierd problem with the memory usage... once i open the program it will keep on draing more memory, it will never stop :D if i minimize the program the memory will dispose(?) and the program will drop to about 2-5mb and start growing again... is it a bug in .net or did i not read something correctly? I thank everyone for intrest in the problem

                        A Offline
                        A Offline
                        asator
                        wrote on last edited by
                        #11

                        Refreshing...

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups