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. Other Discussions
  3. IT & Infrastructure
  4. Limiting available memory to an NT app running on XP?

Limiting available memory to an NT app running on XP?

Scheduled Pinned Locked Moved IT & Infrastructure
helpperformancequestioncssdatabase
5 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.
  • K Offline
    K Offline
    Kent K
    wrote on last edited by
    #1

    We have an application built for windows NT (no updates available from the vendor) back in those times where 512 MB of RAM was a lot. The app will run on windows XP, but only with systems with less than 2 Gigs of RAM (with the VM off) or systems with 1 Gig of ram and the VM set below the amount that in total adds to roughly 2 Gigs. What I think is happening is that the developer of the app does a query of the system's available ram on startup and stores it in a 32 bit int (2 billion, 73 million.... etc bytes), without an overflow check I guess. This is since when, I assume, the value of the variable is checked against a minimum amount of ram, it fails the test and the app throws an error message that not enough memory is available, when in fact there is plenty. This hypothesis is due to being able to run the app on systems with 1 Gig of Ram as mentioned above and the VM limited to not exceed 2 Gigs in total. So, that was my patch before, just set a max limit on the VM. But now we are getting systems with 3 Gigs of ram and I have this issue again now and not an easy of a fix. Even for the other systems that this works on, they are running into performance issues when multiple apps are open too, since we don't change the VM settings back to being system managed after using the app, as that is too inconvenient. . .limiting the VM hurts other apps used on the system. So, my question is, after not finding anything on a net search, does anyone know how I might force the application, in or via win XP to only be given a certain amount of memory?? I've looked into the compatibility features of XP but no setting is available for this. I've thought of having a huge image that the user would open to hog a bunch of ram as a fairly siimple hack, but haven't tried it. Perhaps the OS would just create a larger pagefile in that case anyway. Thoughts anyone? Thanks in advance.

    J 1 Reply Last reply
    0
    • K Kent K

      We have an application built for windows NT (no updates available from the vendor) back in those times where 512 MB of RAM was a lot. The app will run on windows XP, but only with systems with less than 2 Gigs of RAM (with the VM off) or systems with 1 Gig of ram and the VM set below the amount that in total adds to roughly 2 Gigs. What I think is happening is that the developer of the app does a query of the system's available ram on startup and stores it in a 32 bit int (2 billion, 73 million.... etc bytes), without an overflow check I guess. This is since when, I assume, the value of the variable is checked against a minimum amount of ram, it fails the test and the app throws an error message that not enough memory is available, when in fact there is plenty. This hypothesis is due to being able to run the app on systems with 1 Gig of Ram as mentioned above and the VM limited to not exceed 2 Gigs in total. So, that was my patch before, just set a max limit on the VM. But now we are getting systems with 3 Gigs of ram and I have this issue again now and not an easy of a fix. Even for the other systems that this works on, they are running into performance issues when multiple apps are open too, since we don't change the VM settings back to being system managed after using the app, as that is too inconvenient. . .limiting the VM hurts other apps used on the system. So, my question is, after not finding anything on a net search, does anyone know how I might force the application, in or via win XP to only be given a certain amount of memory?? I've looked into the compatibility features of XP but no setting is available for this. I've thought of having a huge image that the user would open to hog a bunch of ram as a fairly siimple hack, but haven't tried it. Perhaps the OS would just create a larger pagefile in that case anyway. Thoughts anyone? Thanks in advance.

      J Offline
      J Offline
      Jorgen Andersson
      wrote on last edited by
      #2

      Will the app run on XP64? You could then confirm the hypothesis by setting the memory to 5 GB which would be seen by the app as 1GB. Another thing you can do to troubleshoot is to set /MAXMEM[^] in boot.ini Or running it in a virtual machine. Just a thought.

      K 1 Reply Last reply
      0
      • J Jorgen Andersson

        Will the app run on XP64? You could then confirm the hypothesis by setting the memory to 5 GB which would be seen by the app as 1GB. Another thing you can do to troubleshoot is to set /MAXMEM[^] in boot.ini Or running it in a virtual machine. Just a thought.

        K Offline
        K Offline
        Kent K
        wrote on last edited by
        #3

        I don't have a system with XP64 to try. So, you can set the available memory to use on a 32 bit app when you launch it on XP64? How does 5GB equate to 1GB to the 32 bit app? I don't know exactly how a 32 bit app would run on a 64 bit OS, but thought the OS might just use half of the 64 bit address space or instruction or whatever. I could try the MAXMEM thing, didn't know about that, thanks. It would be a hassle as it would require a reboot before they used the app then a restart when they left the pc (plus a batch file or something to make the boot.ini file change), but it's a solution. The VM thing might be the best approach so far I guess. . .have to look into that more as if the VM could be launched on demand, the problematic app opened in it and used, then close when done, that would be slick. But, I bet there is more to that and as I said, I haven't played with VMs at all yet. Thanks, Kent

        T J 2 Replies Last reply
        0
        • K Kent K

          I don't have a system with XP64 to try. So, you can set the available memory to use on a 32 bit app when you launch it on XP64? How does 5GB equate to 1GB to the 32 bit app? I don't know exactly how a 32 bit app would run on a 64 bit OS, but thought the OS might just use half of the 64 bit address space or instruction or whatever. I could try the MAXMEM thing, didn't know about that, thanks. It would be a hassle as it would require a reboot before they used the app then a restart when they left the pc (plus a batch file or something to make the boot.ini file change), but it's a solution. The VM thing might be the best approach so far I guess. . .have to look into that more as if the VM could be launched on demand, the problematic app opened in it and used, then close when done, that would be slick. But, I bet there is more to that and as I said, I haven't played with VMs at all yet. Thanks, Kent

          T Offline
          T Offline
          Toby Opferman
          wrote on last edited by
          #4

          Create a DLL that is injected into that process. Determine which API the application is using to determine the memory size, hook that API for this application and fake the return value to that which makes it work correctly. This is essentially what any type of application compatibility setting would have done if none are avaialble.

          8bc7c0ec02c0e404c0cc0680f7018827ebee

          1 Reply Last reply
          0
          • K Kent K

            I don't have a system with XP64 to try. So, you can set the available memory to use on a 32 bit app when you launch it on XP64? How does 5GB equate to 1GB to the 32 bit app? I don't know exactly how a 32 bit app would run on a 64 bit OS, but thought the OS might just use half of the 64 bit address space or instruction or whatever. I could try the MAXMEM thing, didn't know about that, thanks. It would be a hassle as it would require a reboot before they used the app then a restart when they left the pc (plus a batch file or something to make the boot.ini file change), but it's a solution. The VM thing might be the best approach so far I guess. . .have to look into that more as if the VM could be launched on demand, the problematic app opened in it and used, then close when done, that would be slick. But, I bet there is more to that and as I said, I haven't played with VMs at all yet. Thanks, Kent

            J Offline
            J Offline
            Jorgen Andersson
            wrote on last edited by
            #5

            No, I we're just toying around with your hypothesis about a 32 bit Int. 32 bits make 4GB so the 2GB limit should then mean that we're dealing with a signed integer. That would turn negative at 2GB and start over from zero at 4GB. So 5GB would be read as 1GB, but I could be wrong of course. You won't need an extra batchfile to change the boot.ini, that functionality is built in, see here.[^] The rebooting hassle I have no solution for though.

            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