2

In the course of tracking down some memory leaks in the project I'm working on, I've also been working on updating the various hardware API libraries. A couple of these are unmanaged 32bit libraries, which forces our application to compile to x86; this is not a problem in and of itself. I'm working on upgrading these libraries to 64 bit versions so that our application doesn't have to run in 32 bit, but it led me to wonder about memory leaks and the addressable memory space.

Given memory leaks, when running in a 64 bit process, will an application theoretically be able to run for a longer period of time before hitting an OutOfMemoryException? There are at least two cases for this

  • Memory Fragmentation - There is not a contiguous memory block to allocate a large object, so this exception could be thrown even though there appears to be enough free memory

  • Low Physical Memory - There simply isn't enough memory available, contiguous or not, to allocate a new object

Matt
  • 2,682
  • 1
  • 17
  • 24
  • 1
    I'd say no, as long as the total amount of memory is the same. There might be overhead differences. – Bart Friederichs Jan 08 '14 at 15:45
  • 1
    The address space of a 64 bit process is huge compared to a 32 bit process, so you will be able to allocate a lot more before running into problems. – Brian Rasmussen Jan 08 '14 at 15:46
  • 1
    Upvoting on @BartFriederichs comment tells us that you actually don't know how windows manages memory at all. Total amount of physical memory doesn't have anything to do with how much memory can each application actually address and 'use'. – Daniel Mošmondor Jan 08 '14 at 15:50

3 Answers3

1

If you are running out of address space in a 32-bit process, then moving to a 64-bit process will allow you to run much longer. The system may run out of page table resources before you exhaust address space.

If you are running out of room in your pagefile, then your process will have the same amount of memory available regardless of whether it's 32- or 64-bit. In this case, since 64-bit processes require more memory for the same thing (8-byte pointers), it will actually run out of memory sooner than a 32-bit version of the same process.

Gabe
  • 84,912
  • 12
  • 139
  • 238
  • Good point about the same amount of memory available in a 64 bit process vs a 32 bit. – Matt Jan 09 '14 at 14:43
1

Absolutely it will take longer...

However, depending on your machine and the leaking process, HOW MUCH longer can vary...

While x64 can allow for 8TB of memory, your machine most likely won't allow for that. So lets say you have 4GB of ram and a 12GB pagefile, then you will probably have ~14GB of memory available for you to allocate. (The system has some overhead preventing the full 16GB)

Check out this post for more information.

Community
  • 1
  • 1
poy
  • 10,063
  • 9
  • 49
  • 74
  • Thanks for the link. It stands to reason in most cases that the additional memory space would delay the final exception. I posted to see what thoughts or experiences people have had in this situation, though of course I'm hoping to eliminate all the memory leaks; this isn't always easy and I'll have to do it in phases. – Matt Jan 09 '14 at 15:11
0

Of course it will. On x86 systems, you only have about 2GB of memory that is usable to your app. When you leak it all, you're done, no matter how much of physical or otherwise RAM you have.

On x64, it can run for a long long time, exhausting swap file first, and then bringing system to a complete halt.

Daniel Mošmondor
  • 19,718
  • 12
  • 58
  • 99