vc6 set process memory usage

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Macinbomzh
    New Member
    • Nov 2009
    • 11

    vc6 set process memory usage

    How do I take for example 2gb RAM and allow only a specific process to use them?
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Create your own heap with HeapCreate and allocate your memory for yopur process form there.

    This does rather beg the question why would you want to? No process can access data allocated to another process as the virtual memory maps are completely separate.

    Comment

    • Macinbomzh
      New Member
      • Nov 2009
      • 11

      #3
      My program has to make another program run with a specific size of memory
      since it can't be interruped.
      Maybe i should inject the code for allocating memory to another process?
      I know i should ask it as a seperate question but... How do you inject a code
      to another process? or maybe VirtualAllocEx should do?

      Comment

      • donbock
        Recognized Expert Top Contributor
        • Mar 2008
        • 2427

        #4
        Declaring a static memory allocation eliminates the possibility of malloc failing to give you the memory you asked for; instead, the program would fail to load if there wasn't enough memory. (Is that progress?)

        There's another issue though. If your program needs to run quite often then perhaps you want to prevent its memory from being swapped out when some other process needs a lot of virtual memory. On the other hand, if your program accesses its memory often enough then that memory is least likely to be swapped out. I don't know what facilities Windows provides for controlling the swap algorithm.

        Comment

        • Macinbomzh
          New Member
          • Nov 2009
          • 11

          #5
          What actually i need to do is:
          A program running, declaring variables and meanwhile,
          I give the program alot of space to declare the variables and to work for declaring them and i save its state (variables) in a file every X seconds.

          Comment

          Working...