Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: Controlling the Garbage Collector Date: Thu, 21 Jun 2012 15:15:10 -0700 Organization: A noiseless patient Spider Lines: 25 Message-ID: References: <6KSdnTwztJvtR0bSnZ2dnUVZ_t-dnZ2d@giganews.com> <_JmdnUu_Z-scJEHSnZ2dnUVZ_t6dnZ2d@giganews.com> <4fe27687$0$281$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 21 Jun 2012 22:15:15 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="IZQsHU8CwMUPnWgvh4wwWA"; logging-data="11890"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+UlxP1dSu1kcYlBGzFKeZaa2OSsu2kSoc=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: Cancel-Lock: sha1:wR3nOzJB234Hw1BlhBK4CXeyRlI= Xref: csiph.com comp.lang.java.programmer:15497 On 6/21/2012 11:24 AM, Aaron W. Hsu wrote: > On the other side, there are times when I know that I am going to be > doing a number of very small, little allocations all in a row, and I do > not want the GC to run during this tight loop, I believe this is what the Java GC does by default. It allocates large blocks of memory from the OS and then creates new objects in that large block, quickly and efficiently. The only time the GC should run here is if you literally run out of memory and must GC. > Finally, there are times when I want to do a large bulk allocation > outside of the collector, and then selectively move certain things into > the collected space, but still have a checked, high-level way of > accessing data structures in the uncollected space. This sounds basically like System.gc(). System.gc() will run the GC, move objects into one or more permanent generation spaces, and then dump the large blocks of temporary objects. Many things can alter this, and I see you have some special requirements, but the main bits of the Java GC should give you something very close to what you are looking for.