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

Memory

Scheduled Pinned Locked Moved C / C++ / MFC
performancehelptutorialquestion
16 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.
  • D Dave Bryant

    I would strongly suggest that if you don't understand what memory pages are and how they work, then you should just let windows handle the virtual memory. It is very easy to screw it up, and is not recommended while you're still trying to learn the basics. Dave http://www.cloudsofheaven.org

    H Offline
    H Offline
    Hosam Aly Mahmoud
    wrote on last edited by
    #7

    Thank you for your reply. I would have let windows handle everything in normal situations, but I am currently working on a program that needs full processor power and enough RAM to use as a buffer. I had a problem with the buffer size though, so I thought it would be adequate to ask the system how much free RAM it has and then allocate most of it. I certainly need to make sure that my buffer does not go into virtual memory, because that would buffer something from the HDD to the HDD, right? That said, I want to learn the new concepts I neaded, so please give me a link or a hint where to find the information I need. By the way, could you please tell me how to give my process higher priority? Thank you very much.

    Hosam Aly Mahmoud

    J 2 Replies Last reply
    0
    • H Hosam Aly Mahmoud

      Thank you for your reply. I would have let windows handle everything in normal situations, but I am currently working on a program that needs full processor power and enough RAM to use as a buffer. I had a problem with the buffer size though, so I thought it would be adequate to ask the system how much free RAM it has and then allocate most of it. I certainly need to make sure that my buffer does not go into virtual memory, because that would buffer something from the HDD to the HDD, right? That said, I want to learn the new concepts I neaded, so please give me a link or a hint where to find the information I need. By the way, could you please tell me how to give my process higher priority? Thank you very much.

      Hosam Aly Mahmoud

      J Offline
      J Offline
      John M Drescher
      wrote on last edited by
      #8

      I have no clue how big a buffer you are allocating but I just wanted to inform you for all practical purposes on a 32 bit version of Windows that is not advanced server or greater you can not allocate a buffer greater than about 1.2GB because of several reasons that have to do with how process memory is partitioned. John

      H 1 Reply Last reply
      0
      • H Hosam Aly Mahmoud

        Thank you very much. The GlobalMemoryStatus() is great. But I could not understand VirtualLock(). Could you kindly help me with it?

        Hosam Aly Mahmoud

        J Offline
        J Offline
        John M Drescher
        wrote on last edited by
        #9

        I'll see what I can find. Here is an article that better describes what VirtualLock does. http://www.privacy.nb.ca/cryptography/archives/coderpunks/new/1999-02/0160.html[^] [EDIT] Here is an old link that shows a few examples of using virtual memory functions: http://www.labri.fr/Perso/~betrema/winnt/virtmm.html[^] [/EDIT] John

        H 1 Reply Last reply
        0
        • H Hosam Aly Mahmoud

          Thank you for your reply. I would have let windows handle everything in normal situations, but I am currently working on a program that needs full processor power and enough RAM to use as a buffer. I had a problem with the buffer size though, so I thought it would be adequate to ask the system how much free RAM it has and then allocate most of it. I certainly need to make sure that my buffer does not go into virtual memory, because that would buffer something from the HDD to the HDD, right? That said, I want to learn the new concepts I neaded, so please give me a link or a hint where to find the information I need. By the way, could you please tell me how to give my process higher priority? Thank you very much.

          Hosam Aly Mahmoud

          J Offline
          J Offline
          John M Drescher
          wrote on last edited by
          #10

          Here is a good tutorial about Memory Management, it’s a little old and mentions 16 bit windows and RISC stuff that you should not be very concerned with: http://www.jps.at/dev/kurs/3-2.html[^] John

          1 Reply Last reply
          0
          • J John M Drescher

            I'll see what I can find. Here is an article that better describes what VirtualLock does. http://www.privacy.nb.ca/cryptography/archives/coderpunks/new/1999-02/0160.html[^] [EDIT] Here is an old link that shows a few examples of using virtual memory functions: http://www.labri.fr/Perso/~betrema/winnt/virtmm.html[^] [/EDIT] John

            H Offline
            H Offline
            Hosam Aly Mahmoud
            wrote on last edited by
            #11

            Thank you for your reply, and sorry for my late reply. I read the two links, and thanks a lot for the second one. The first one, however, made me rethink about using VirtualLock(). But I think that if my application does not lose focus, then it will keep my application fast. Is that right? Now I have another problem: how can I keep my application in the foreground? Should I make my process' priority "Real Time"? How can I do that? Thank you very much.

            Hosam Aly Mahmoud

            J 1 Reply Last reply
            0
            • J John M Drescher

              I have no clue how big a buffer you are allocating but I just wanted to inform you for all practical purposes on a 32 bit version of Windows that is not advanced server or greater you can not allocate a buffer greater than about 1.2GB because of several reasons that have to do with how process memory is partitioned. John

              H Offline
              H Offline
              Hosam Aly Mahmoud
              wrote on last edited by
              #12

              Thank you for the information.

              Hosam Aly Mahmoud

              1 Reply Last reply
              0
              • H Hosam Aly Mahmoud

                Thank you for your reply, and sorry for my late reply. I read the two links, and thanks a lot for the second one. The first one, however, made me rethink about using VirtualLock(). But I think that if my application does not lose focus, then it will keep my application fast. Is that right? Now I have another problem: how can I keep my application in the foreground? Should I make my process' priority "Real Time"? How can I do that? Thank you very much.

                Hosam Aly Mahmoud

                J Offline
                J Offline
                John M Drescher
                wrote on last edited by
                #13

                Hosam Aly Mahmoud wrote: But I think that if my application does not lose focus, then it will keep my application fast. Yes it will. As long as the application is not minimized it will not page out unless another process needs memory. When the application is minimized windows sets the working set size to zero thus paging out your application. Different windows versions will handle this alittle differently. I think NT4 will page all of your applicaton out immediatly causing a long delay. I am a little unsure of this. I worked on this two years ago for an application that needed to hold 256MB of images in memory at a time. Hosam Aly Mahmoud wrote: how can I keep my application in the foreground? Don't allow the main window to be minimized. I made the minimize button hide the window instead of minimize and it fixed the problem. John

                H 1 Reply Last reply
                0
                • J John M Drescher

                  Hosam Aly Mahmoud wrote: But I think that if my application does not lose focus, then it will keep my application fast. Yes it will. As long as the application is not minimized it will not page out unless another process needs memory. When the application is minimized windows sets the working set size to zero thus paging out your application. Different windows versions will handle this alittle differently. I think NT4 will page all of your applicaton out immediatly causing a long delay. I am a little unsure of this. I worked on this two years ago for an application that needed to hold 256MB of images in memory at a time. Hosam Aly Mahmoud wrote: how can I keep my application in the foreground? Don't allow the main window to be minimized. I made the minimize button hide the window instead of minimize and it fixed the problem. John

                  H Offline
                  H Offline
                  Hosam Aly Mahmoud
                  wrote on last edited by
                  #14

                  Thanks for your efforts and time. John M. Drescher wrote: I made the minimize button hide the window instead of minimize and it fixed the problem I think I will disable the minimize button. That should be enough. John M. Drescher wrote: As long as the application is not minimized it will not page out unless another process needs memory. So what if another process does need memory? How can I delay all other processes and make them wait until I am finished?

                  Hosam Aly Mahmoud

                  J 1 Reply Last reply
                  0
                  • H Hosam Aly Mahmoud

                    Thanks for your efforts and time. John M. Drescher wrote: I made the minimize button hide the window instead of minimize and it fixed the problem I think I will disable the minimize button. That should be enough. John M. Drescher wrote: As long as the application is not minimized it will not page out unless another process needs memory. So what if another process does need memory? How can I delay all other processes and make them wait until I am finished?

                    Hosam Aly Mahmoud

                    J Offline
                    J Offline
                    John M Drescher
                    wrote on last edited by
                    #15

                    Hosam Aly Mahmoud wrote: So what if another process does need memory? How can I delay all other processes and make them wait until I am finished? If another process needs memory it may affect the working set of your process. When all the physical memory of the system is exausted the cpu will trim the working set of all processes (other than the one requesting additional memory). Hosam Aly Mahmoud wrote: How can I delay all other processes and make them wait until I am finished? Maybe setting the process priority to real time may solve your problem. John

                    H 1 Reply Last reply
                    0
                    • J John M Drescher

                      Hosam Aly Mahmoud wrote: So what if another process does need memory? How can I delay all other processes and make them wait until I am finished? If another process needs memory it may affect the working set of your process. When all the physical memory of the system is exausted the cpu will trim the working set of all processes (other than the one requesting additional memory). Hosam Aly Mahmoud wrote: How can I delay all other processes and make them wait until I am finished? Maybe setting the process priority to real time may solve your problem. John

                      H Offline
                      H Offline
                      Hosam Aly Mahmoud
                      wrote on last edited by
                      #16

                      Thank you very much for your help John! I do not know how I could thank you, but here is a try: :rose: :) John M. Drescher wrote: Maybe setting the process priority to real time may solve your problem. I thought it would, but I do not know how to do it. Could you please tell me (or give me a link)? I would very much appreciate it. Thank you for all your help!

                      Hosam Aly Mahmoud

                      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