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 / C++ / MFC
  4. Windows console application freeing up RAM memory

Windows console application freeing up RAM memory

Scheduled Pinned Locked Moved C / C++ / MFC
csharpvisual-studioperformancehelpquestion
19 Posts 9 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.
  • H Hamid Taebi

    You need to free memory that you used(of course if your language was C# you didnt need to do it because it frees memory auomaticaly).

    Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

    P Offline
    P Offline
    ParagPatel
    wrote on last edited by
    #4

    Hi Hamid, I don't know that much about c# but how language does matter when your application kiled?

    Parag Patel Sr. Software Eng, Varaha Systems

    R H E 3 Replies Last reply
    0
    • R radus215

      hi everybody! I am writing Windows console application with Microsoft Visual Studio 2008 (using C only) which needs to allocate big amounts of RAM memory with malloc() anc calloc(). The execution of program can be stopped anytime by user pressing CTRL+C keys or by shutting down console window. What happens to previously allocated memory when it happens? Is it freed up by the system automatically (I guess not?) or do I need to keep track of allocated memory blocks and free() them all myself when the application receives close signal? If this is the case can anybody direct me to any C code solving this problem? Thank you in advance,Radek

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #5

      First of all, why are you writing such a rogue program that would do nothing good but allocate huge amounts of physical memory? Tell me the name of your program. I must be sure never to use it!

      It is a crappy thing, but it's life -^ Carlo Pallini

      C 1 Reply Last reply
      0
      • P ParagPatel

        Hi Hamid, I don't know that much about c# but how language does matter when your application kiled?

        Parag Patel Sr. Software Eng, Varaha Systems

        R Offline
        R Offline
        Rajesh R Subramanian
        wrote on last edited by
        #6

        Because the there's a thing called Garbage collector[^], which automatically takes care of all memory de-allocations in case of C# or any other CLI languages.

        It is a crappy thing, but it's life -^ Carlo Pallini

        D 1 Reply Last reply
        0
        • R Rajesh R Subramanian

          Because the there's a thing called Garbage collector[^], which automatically takes care of all memory de-allocations in case of C# or any other CLI languages.

          It is a crappy thing, but it's life -^ Carlo Pallini

          D Offline
          D Offline
          Divyang Mithaiwala
          wrote on last edited by
          #7

          I am not clear about C# but as per your answer is it same like JVM used in java? Which take care about memory management.


          Do not trust a computer... Always check what computer is doing regards, Divyang Mithaiwala Software Engineer

          C 1 Reply Last reply
          0
          • D Divyang Mithaiwala

            I am not clear about C# but as per your answer is it same like JVM used in java? Which take care about memory management.


            Do not trust a computer... Always check what computer is doing regards, Divyang Mithaiwala Software Engineer

            C Offline
            C Offline
            Cedric Moonen
            wrote on last edited by
            #8

            Divyang Mithaiwala wrote:

            I am not clear about C# but as per your answer is it same like JVM used in java?

            No, in Java it is also called the garbage collector. I guess you are a bit confused about the names. JVM stands for Java Virtual Machine.

            Cédric Moonen Software developer
            Charting control [v1.5] OpenGL game tutorial in C++

            D 1 Reply Last reply
            0
            • R Rajesh R Subramanian

              First of all, why are you writing such a rogue program that would do nothing good but allocate huge amounts of physical memory? Tell me the name of your program. I must be sure never to use it!

              It is a crappy thing, but it's life -^ Carlo Pallini

              C Offline
              C Offline
              CPallini
              wrote on last edited by
              #9

              Rajesh R Subramanian wrote:

              Tell me the name of your program. I must be sure never to use it!

              Vista. ;P Well...No, I'm wrong Vista uses all that memory in order to prevent you to access system's resources... :rolleyes:

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              R H 2 Replies Last reply
              0
              • R radus215

                hi everybody! I am writing Windows console application with Microsoft Visual Studio 2008 (using C only) which needs to allocate big amounts of RAM memory with malloc() anc calloc(). The execution of program can be stopped anytime by user pressing CTRL+C keys or by shutting down console window. What happens to previously allocated memory when it happens? Is it freed up by the system automatically (I guess not?) or do I need to keep track of allocated memory blocks and free() them all myself when the application receives close signal? If this is the case can anybody direct me to any C code solving this problem? Thank you in advance,Radek

                L Offline
                L Offline
                Luc 648011
                wrote on last edited by
                #10

                When a Windows process exits all its resources get freed automatically, including memory, whatever its programming language or technology is. :)

                1 Reply Last reply
                0
                • C CPallini

                  Rajesh R Subramanian wrote:

                  Tell me the name of your program. I must be sure never to use it!

                  Vista. ;P Well...No, I'm wrong Vista uses all that memory in order to prevent you to access system's resources... :rolleyes:

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                  [My articles]

                  R Offline
                  R Offline
                  Rajesh R Subramanian
                  wrote on last edited by
                  #11

                  Actually, in this case, I would like to defend Vista. It just tries and fills up available physical memory with programs that you consecutively use (XP does not do that, so there's plenty of free available memory shown up in the task manager) so that the next time you open the program, it is opened fast. A pretty good idea if you ask me. :) Joke: Except for the fact that I would not want my physical memory to be filled up with my father's accounts excel sheets when I try to play far cry. :laugh:

                  It is a crappy thing, but it's life -^ Carlo Pallini

                  C 1 Reply Last reply
                  0
                  • R radus215

                    hi everybody! I am writing Windows console application with Microsoft Visual Studio 2008 (using C only) which needs to allocate big amounts of RAM memory with malloc() anc calloc(). The execution of program can be stopped anytime by user pressing CTRL+C keys or by shutting down console window. What happens to previously allocated memory when it happens? Is it freed up by the system automatically (I guess not?) or do I need to keep track of allocated memory blocks and free() them all myself when the application receives close signal? If this is the case can anybody direct me to any C code solving this problem? Thank you in advance,Radek

                    C Offline
                    C Offline
                    CPallini
                    wrote on last edited by
                    #12

                    Making cleanup is fundamental task the wise C/C++ programmer. That said, when a process is terminated, the OS frees automatically the allocated memory. :)

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                    [My articles]

                    1 Reply Last reply
                    0
                    • C Cedric Moonen

                      Divyang Mithaiwala wrote:

                      I am not clear about C# but as per your answer is it same like JVM used in java?

                      No, in Java it is also called the garbage collector. I guess you are a bit confused about the names. JVM stands for Java Virtual Machine.

                      Cédric Moonen Software developer
                      Charting control [v1.5] OpenGL game tutorial in C++

                      D Offline
                      D Offline
                      Divyang Mithaiwala
                      wrote on last edited by
                      #13

                      Cedric Moonen wrote:

                      No, in Java it is also called the garbage collector.

                      Yes it is garbage collector. But it is part of JVM. Because at compile time java compiler not going to put code related to garbage collection.


                      Do not trust a computer... Always check what computer is doing regards, Divyang Mithaiwala Software Engineer

                      1 Reply Last reply
                      0
                      • R Rajesh R Subramanian

                        Actually, in this case, I would like to defend Vista. It just tries and fills up available physical memory with programs that you consecutively use (XP does not do that, so there's plenty of free available memory shown up in the task manager) so that the next time you open the program, it is opened fast. A pretty good idea if you ask me. :) Joke: Except for the fact that I would not want my physical memory to be filled up with my father's accounts excel sheets when I try to play far cry. :laugh:

                        It is a crappy thing, but it's life -^ Carlo Pallini

                        C Offline
                        C Offline
                        CPallini
                        wrote on last edited by
                        #14

                        Rajesh R Subramanian wrote:

                        it is opened fast. A pretty good idea if you ask me.

                        Yes, it is good, if you've a lot of bloated-garbage-collected-applications... Just kidding, you're right, but, I suppose this is not a new idea, Linux applications had sticky bits since a long time.

                        Rajesh R Subramanian wrote:

                        Joke: Except for the fact that I would not want my physical memory to be filled up with my father's accounts excel sheets when I try to play far cry.

                        You're a very lucky man: my physical memory is filled by my wife talking and talking and talking...:laugh:

                        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                        [My articles]

                        R 1 Reply Last reply
                        0
                        • C CPallini

                          Rajesh R Subramanian wrote:

                          it is opened fast. A pretty good idea if you ask me.

                          Yes, it is good, if you've a lot of bloated-garbage-collected-applications... Just kidding, you're right, but, I suppose this is not a new idea, Linux applications had sticky bits since a long time.

                          Rajesh R Subramanian wrote:

                          Joke: Except for the fact that I would not want my physical memory to be filled up with my father's accounts excel sheets when I try to play far cry.

                          You're a very lucky man: my physical memory is filled by my wife talking and talking and talking...:laugh:

                          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                          [My articles]

                          R Offline
                          R Offline
                          Rajesh R Subramanian
                          wrote on last edited by
                          #15

                          CPallini wrote:

                          ...not a new idea, Linux applications had sticky bits ...

                          Ugh... What is Linux? I'd like a plate of it, preferably with fries. :laugh:

                          It is a crappy thing, but it's life -^ Carlo Pallini

                          C 1 Reply Last reply
                          0
                          • R Rajesh R Subramanian

                            CPallini wrote:

                            ...not a new idea, Linux applications had sticky bits ...

                            Ugh... What is Linux? I'd like a plate of it, preferably with fries. :laugh:

                            It is a crappy thing, but it's life -^ Carlo Pallini

                            C Offline
                            C Offline
                            CPallini
                            wrote on last edited by
                            #16

                            Oh yes: Lunix, La Sapienza & French fries! :laugh: I should know we two are the best in THHBing :-D

                            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                            [My articles]

                            1 Reply Last reply
                            0
                            • C CPallini

                              Rajesh R Subramanian wrote:

                              Tell me the name of your program. I must be sure never to use it!

                              Vista. ;P Well...No, I'm wrong Vista uses all that memory in order to prevent you to access system's resources... :rolleyes:

                              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                              [My articles]

                              H Offline
                              H Offline
                              Hamid Taebi
                              wrote on last edited by
                              #17

                              Management memory at vista is differennt with XP,It cached all memory of your system for more speed. :)

                              Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                              1 Reply Last reply
                              0
                              • P ParagPatel

                                Hi Hamid, I don't know that much about c# but how language does matter when your application kiled?

                                Parag Patel Sr. Software Eng, Varaha Systems

                                H Offline
                                H Offline
                                Hamid Taebi
                                wrote on last edited by
                                #18

                                It seems I came late,your answer was Garbage Collection and its the .Net method.

                                Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                                1 Reply Last reply
                                0
                                • P ParagPatel

                                  Hi Hamid, I don't know that much about c# but how language does matter when your application kiled?

                                  Parag Patel Sr. Software Eng, Varaha Systems

                                  E Offline
                                  E Offline
                                  Eytukan
                                  wrote on last edited by
                                  #19

                                  ParagPatel wrote:

                                  I don't know that much about c# but how language does matter when your application kiled?

                                  That's true. When your application gets terminated, you really don't have to worry about the memory it was using. All those get wiped off.

                                  Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

                                  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