Hello R developers, Windows 2000 R Version 1.2.2 I am running using R.dll in a Windows application. It is loaded into memory when needed, used as required, and then (hopefully) destroyed while the application continues with other, unrelated activities. The problem is that I can't find any way to free all memory used by R without terminating the process in which R is running, which I cannot do because that would also kill the host application. Is there a way to locate and free all memory allocated by R.dll, leaving the host process intact? Thank you, Don Wingate. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Wed, 18 Apr 2001, Don Wingate wrote:> Hello R developers, > > Windows 2000 > R Version 1.2.2 > > I am running using R.dll in a Windows application. It is loaded into memory > when needed, used as required, and then (hopefully) destroyed while the > application continues with other, unrelated activities. The problem is that > I can't find any way to free all memory used by R without terminating the > process in which R is running, which I cannot do because that would also > kill the host application. Is there a way to locate and free all memory > allocated by R.dll, leaving the host process intact? >In general you can't release memory to the operating system: under most malloc's and most OS's the memory you free() just stays allocated. You might be able to unload the R dll; I don't know what effect that has under Windows. However, any halfway competent virtual memory system (which nowadays does include Windows) will end up paging out the memory if it is never used, so it shouldn't help much even if you could release all the memory. -thomas Thomas Lumley Asst. Professor, Biostatistics tlumley@u.washington.edu University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Wed, 18 Apr 2001, Don Wingate wrote:> Hello R developers, > > Windows 2000 > R Version 1.2.2 > > I am running using R.dll in a Windows application. It is loaded into memory > when needed, used as required, and then (hopefully) destroyed while the > application continues with other, unrelated activities. The problem is that > I can't find any way to free all memory used by R without terminating the > process in which R is running, which I cannot do because that would also > kill the host application. Is there a way to locate and free all memory > allocated by R.dll, leaving the host process intact?Yes, but if you are using R.dll at that level you will have already read all the code, so you will know that R.dll uses its own allocator in malloc.c and so how to do this. BTW, although you can decommit all the memory, you cannot easily unreserve it. If the difference means nothing to you, then I suggest you don't mess with this. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Under linux (actually libc6), the strategy is to mmap /dev/zero for large allocations. Unmapping this memory does return it to the system, unlike traditional malloc implementations that only release memory after the process terminates. I don't know if there is an equivalent in windows. Tim Don Wingate wrote:> Hello R developers, > > Windows 2000 > R Version 1.2.2 > > I am running using R.dll in a Windows application. It is loaded into memory > when needed, used as required, and then (hopefully) destroyed while the > application continues with other, unrelated activities. The problem is that > I can't find any way to free all memory used by R without terminating the > process in which R is running, which I cannot do because that would also > kill the host application. Is there a way to locate and free all memory > allocated by R.dll, leaving the host process intact? > > Thank you, > > Don Wingate. > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- Timothy H. Keitt Department of Ecology and Evolution State University of New York at Stony Brook Phone: 631-632-1101, FAX: 631-632-7626 http://life.bio.sunysb.edu/ee/keitt/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
The trouble is that the lost memory is building up in the process space of my host application. The R dll might be loaded and unloaded several times in a single session, each time allocating more memory for itself. To the best of my ability to determine, when the dll is unloaded, the memory that it allocated, as well as any dll's it might have loaded for its own use, stay in memory. Don. On Wed, 18 Apr 2001, Don Wingate wrote:> Hello R developers, > > Windows 2000 > R Version 1.2.2 > > I am running using R.dll in a Windows application. It is loaded intomemory> when needed, used as required, and then (hopefully) destroyed while the > application continues with other, unrelated activities. The problem isthat> I can't find any way to free all memory used by R without terminating the > process in which R is running, which I cannot do because that would also > kill the host application. Is there a way to locate and free all memory > allocated by R.dll, leaving the host process intact? >In general you can't release memory to the operating system: under most malloc's and most OS's the memory you free() just stays allocated. You might be able to unload the R dll; I don't know what effect that has under Windows. However, any halfway competent virtual memory system (which nowadays does include Windows) will end up paging out the memory if it is never used, so it shouldn't help much even if you could release all the memory. -thomas Thomas Lumley Asst. Professor, Biostatistics tlumley@u.washington.edu University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._