Stop truecrypt from consuming all available physical memory

1

I have many truecrypt containers that contain random files that I am trying to consolidate into another set of containers that are better organized this time.

To do this requires me to copy all the contents of every container that I have into a central location where I can better categorize these files.

While carrying out this operation, I have noticed that as I read contents from a mounted container, my available physical memory falls linearly until available is consumed.

This physical memory is released/made available only when I dismount the container(s).

Hence it appears to me that the truecrypt driver itself is caching file contents of the container(s) in memory with the expectation that once a file is read, it will be again sometime in the future (which is very incorrect in my use case as I don't read the file again once it's been read from the container and copied to another drive).

Because all available physical memory is consumed by truecrypt, I find it very difficult to use my computer until I dismount the volume, and I have 16GB DDR3 RAM on my system!.

I don't want truecrypt to consume all available physical memory - how do I make it consume a fraction (0.5, 0.7, etc) of available physical memory instead?

Using Windows 7 SP1, x64.

PoorLuzer

Posted 2012-12-31T04:06:39.350

Reputation: 590

You're not running Windows 8 by any chance are you? – Sam – 2012-12-31T04:15:39.290

Yes, please identify the specific operating system and vendor distribution you are using? Without this information an accurate answer is not very likely. – mdpc – 2012-12-31T04:19:23.343

Windows 7 SP1, x64 – PoorLuzer – 2012-12-31T07:16:24.460

You kind of didn't describe the problem at all. You say "I find it very difficult to use my computer", but you don't say why. What actual problem do you have? Are some operations slow? Are you getting error messages? – David Schwartz – 2012-12-31T07:21:32.187

@DavidSchwartz: I believe the "problem" is that the program consumes all physical memory! To elaborate (seriously?) consider that I need to play a game while files are being read off a Truecrypt volume - this game will take ages to load as I now have atleast two programs fighting over the available physical memory! Am I the only person who is facing this issue? – PoorLuzer – 2012-12-31T10:49:09.077

1

@PoorLuzer: That's not how memory works on any modern operating system. Modern operating systems can allow physical memory to be used for whatever is the most efficient use of that memory at any particular time. If you need to play a game, physical memory will rapidly be reassigned to the game and the cached data will be discarded. (Under memory pressure, memory is taken from whatever is making the least important use of it. Memory need not be wasted to be used.) See this answer which discusses a similar issue.

– David Schwartz – 2012-12-31T18:36:04.953

@DavidSchwartz: I want to intentionally limit the memory that TrueCrypt can use (analogous to ulimit) as it does not seem to release the memory until a container is unmounted. Hence, the OS needs to do a lot of thrashing to load any other application or extend the memory needs of an already loaded application. – PoorLuzer – 2013-01-01T03:27:03.790

Answers

2

Modern operating systems do not need memory to be free. They can directly switch memory from one use to another. So there is no harm in having almost all of your physical memory in use. It will still be just as available should you want to use it for something else later.

You are thinking "I want that memory to be free now so I can use it later". But that really doesn't make any sense. Memory doesn't need to be free now to be used later. If some application needs 4GB of memory in a minute, the operating system will give it those 4GB whether or not they are free now. You can use that memory now for one thing and use it for something else later. You don't have to make sacrifices. You can have a huge cache now and throw it away in a split second should your system's memory needs change.

If you are having some actual performance problem, describe it. But modern operating systems go out of their way not to waste memory by having it just sitting around doing nothing. If there's anything they can possibly use it for, they do.

The analogy I use is a guy who walks into a factory where everyone is working and asks, "Why aren't there a bunch of employees sitting on the couch doing nothing just in case there's some work that needs to be done later?" And the answer is -- because there's work to be done now. If there's work to be done later, then they'll do that work later. They don't need to be sitting on the couch doing nothing now just so they can work later. They can work now and later. There is no need to make sacrifices.

David Schwartz

Posted 2012-12-31T04:06:39.350

Reputation: 58 310

1Isn't there's a difference between the OS caching memory (good) and an app using a huge bunch of memory (possibly bad)? At the least, loading another big app will force the OS to swap data to disk which will cause some slowdows. The OS isn't going to simply discard an app's data like it does for its own cache. SQL server is a notable exception: you can let it use all your ram, but it will release it if an app or the OS requests memory. Most applications don't do that, do they. (Note: It's not clear from OP whether he's refering to OS cache usage or actual app usage.) – mtone – 2013-01-01T00:57:19.830

@mtone: Properly-designed applications that use large amounts of caching arrange with the operating system to manage the amount of cache the application uses. Only a horribly broken design would require large amounts of memory to sit idle if there was anything useful that memory could do. – David Schwartz – 2013-01-01T02:04:30.833

Heed mtone's comment - the memory is not being used directly by Win7 but consumed by TrueCrypt and a lot of thrashing is happening when I load another program after TrueCrypt. Hence, either I will need to load the game first and then TrueCrypt (it has less memory to consume) or wait an eternity for the game to load (as thrashing is happening). Issue is "truecrypt's consuming all available physical memory"; if you insist, I am considering rephrasing it to "truecrypt's consuming all available physical memory and it ain't play nice with others when they want a piece of it" – PoorLuzer – 2013-01-01T03:21:18.577

TrueCrypt, from the behaviors I am seeing is one of those "Only a horribly broken design would require large amounts of memory to sit idle if there was anything useful that memory could do" that you mention. What tools can I run so that we can have some reports to look at what's going on? – PoorLuzer – 2013-01-01T03:23:11.883

1If that was true, there would be dozens of complaints about it. Yet this is the only one I see. That suggests the problem is more likely something unusual about your particular case. – David Schwartz – 2013-01-01T19:37:05.787

Hmm, I think so as well, but I am unsure how I can track it down. What tools can help me out find the root cause? – PoorLuzer – 2013-01-01T20:43:36.280

Can you think of anything unusual about your setup? Unusual hardware? Unusual software? Unusual system settings or tuning? Unusual paging or swap settings? – David Schwartz – 2013-01-01T20:50:53.790