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. Pre-allocation of virtual memory

Pre-allocation of virtual memory

Scheduled Pinned Locked Moved C / C++ / MFC
cssperformancehelpquestion
4 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 Offline
    D Offline
    De Nardis Andrea
    wrote on last edited by
    #1

    Hi all, Is there a way to pre-allocate some large amount of virtual memory for a process and then let it use? I have the following problem: there is a very important service that use large amount of memory (up to 400MB and more) but its memory usage depends on time: sometime uses as low as 4MB of memory, sometimes 400MB. Sometimes it happens that it cannot find 400MB free because other less important processes uses it. A possible solution would be to pre-allocate 400MB, and then let 'malloc' and 'new' allocate from the pre-allocated pool. Do you know a way to do it in W2K/XP? Thanks a lot in advance. Regards, Andrea

    K J 2 Replies Last reply
    0
    • D De Nardis Andrea

      Hi all, Is there a way to pre-allocate some large amount of virtual memory for a process and then let it use? I have the following problem: there is a very important service that use large amount of memory (up to 400MB and more) but its memory usage depends on time: sometime uses as low as 4MB of memory, sometimes 400MB. Sometimes it happens that it cannot find 400MB free because other less important processes uses it. A possible solution would be to pre-allocate 400MB, and then let 'malloc' and 'new' allocate from the pre-allocated pool. Do you know a way to do it in W2K/XP? Thanks a lot in advance. Regards, Andrea

      K Offline
      K Offline
      krmed
      wrote on last edited by
      #2

      You could overload the new operator and handle the details yourself... See MSDN article "How to overload new..." http://support.microsoft.com/default.aspx?scid=kb;en-us;139638[^] Hope that helps. Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

      1 Reply Last reply
      0
      • D De Nardis Andrea

        Hi all, Is there a way to pre-allocate some large amount of virtual memory for a process and then let it use? I have the following problem: there is a very important service that use large amount of memory (up to 400MB and more) but its memory usage depends on time: sometime uses as low as 4MB of memory, sometimes 400MB. Sometimes it happens that it cannot find 400MB free because other less important processes uses it. A possible solution would be to pre-allocate 400MB, and then let 'malloc' and 'new' allocate from the pre-allocated pool. Do you know a way to do it in W2K/XP? Thanks a lot in advance. Regards, Andrea

        J Offline
        J Offline
        Jack Puppy
        wrote on last edited by
        #3

        Did you try VirtualAlloc?

        :suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
        Painted on the side of a dog trainer's van: SIT HAPPENS

        D 1 Reply Last reply
        0
        • J Jack Puppy

          Did you try VirtualAlloc?

          :suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
          Painted on the side of a dog trainer's van: SIT HAPPENS

          D Offline
          D Offline
          De Nardis Andrea
          wrote on last edited by
          #4

          Hi, unfortunately I have to reserve a large amount of global virtual memory because virtual memory (either physical or in page file) is a shared, limited resource. The article about the heap should fit but I still do not undestand how to use STL::new and malloc without making custom allocation classes. So the problem is still open... regards, Andrea

          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