11.07.2015 Views

[U] User's Guide

[U] User's Guide

[U] User's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6.5 Virtual memory and speed considerations[ U ] 6.6 An issue when returning memory to Unix 67When you use more memory than is physically available on your computer, Stata slows down. Ifyou are only using a little more memory than on your computer, performance is probably not too bad.On the other hand, when you are using a lot more memory than is on your computer, performancewill be noticeably affected. In these cases, we recommend that you. set virtual onVirtual memory systems exploit locality of reference, which means that keeping objects closertogether allows virtual memory systems to run faster. set virtual controls whether Stata shouldperform extra work to arrange its memory to keep objects close together. By default, virtual isset off. set virtual can be used with Stata/MP, Stata/SE, and Stata/IC on all supported operatingsystems.In general, you want to leave set virtual set to the default of off so that Stata will run faster.When you set virtual on, you are asking Stata to arrange its memory so that objects arekept closer together. This requires Stata to do a substantial amount of work. We recommend settingvirtual on only when the amount of memory in use drastically exceeds what is physically available.In these cases, setting virtual on will help, but performance will still be slow. If you are usingvirtual memory often, you should consider adding memory to your computer.6.6 An issue when returning memory to UnixThere is a surprising issue of returning memory that Unix users need to understand. Let’s say thatyou set memory to 128 megabytes, went along for a while, and then, being a good citizen, returnedmost of it:. set memory 2m(2048k)Theoretically, 126 megabytes was returned to the operating system for use by other processes. Ifyou use Mac or Windows, that is exactly what happens and, with some Unix systems, that is whathappens, too.Other Unix systems, however, are strange about returned memory in a misguided effort to beefficient: they do not really take the memory back. Instead, they leave it allocated to you in case youask for it back later. Still other Unix systems sort of take the memory back: they put it in a queuefor your use, but, if you do not ask for it back in 5 or 10 minutes, then they return it to the realsystem pool!The unfortunate situation is that we, at Stata, cannot force the operating system to take the memoryback. Stata returns the memory to Unix, and then Unix does whatever it wants with it.So, let’s review: you make your Stata smaller in an effort to be a good citizen. You return thememory so that other users can use it, or perhaps so you can use it with some other software.If you use Windows, the memory really is returned and all works exactly as you anticipated.If you use Unix, it might go back immediately, it might go back in 5 or 10 minutes, or it mightnever go back. In the last case, the only way to really return the memory is to exit Stata. All Unixsystems agree on that: when a process ends, the memory really does go back into the pool.To find out how your Unix works, you need to experiment. We would publish a table and just tellyou, but we have found that within manufacturer the way their Unix works will vary by subrelease!The experiment is tedious but not difficult:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!