Hello Guest

[CLOSED] 2.8.1 Memory issues?

  • 5 Replies
  • 4887 Views
[CLOSED] 2.8.1 Memory issues?
« on: October 23, 2011, 22:17:50 »
Hi all,

In updating my LWJGL-based game engine from 2.7.1 to 2.8.1, I'm suddenly seeing major memory consumption issues that I didn't have before. Is anyone else seeing this?

I'm running Java 6 on Win7/64. Working on getting a usable heap dump with jconsole. I'll post a followup if anything usable comes from the heap dump.

Steve

Re: [BUG] 2.8.1 Memory issues?
« Reply #1 on: October 24, 2011, 00:12:59 »
The heapdump result showed that large numbers of DirectByteBuffers were being accumulated on the heap along with a DirectByteBuffer$Deallocator class and a sun.misc.Cleaner class for each instance.

Turns out that my engine was creating the buffers on each pass through the main loop, so I was able to solve my immediate problem by reusing the buffers I had created. However, since this behavior did not appear in 2.7.1, I wonder if something is broken in whatever performs finalization on the byte buffers?

Steve

*

Offline Chuck

  • *
  • 42
  • aka sproingie on freenode
Re: [BUG] 2.8.1 Memory issues?
« Reply #2 on: October 24, 2011, 16:50:23 »
You definitely don't want to allocate DirectByteBuffers in a loop -- they have a ton of creation overhead.  What does the heap dump say was holding the references to the DirectByteBuffer instances?

Re: [BUG] 2.8.1 Memory issues?
« Reply #3 on: October 24, 2011, 17:48:55 »
The references were held by the sun.misc.Cleaner instances. Presumably, they were in the process of being GC'd, but were never actually released.

And I was glad to find that I was creating them in the loop. I hadn't intended to do so, and the memory issues at least brought that to my attention.  Of course, I do still have circumstances where I'll want to create and release buffers at runtime (not in the main loop, but as the game progresses), so I think it's still important to find the cause, especially since it appears to be related to the 2.8.X release (I saw the problem with both 2.8.0 and 2.8.1, but not 2.7.1).

Steve

*

Offline Chuck

  • *
  • 42
  • aka sproingie on freenode
Re: [BUG] 2.8.1 Memory issues?
« Reply #4 on: October 24, 2011, 18:16:07 »
DirectBuffer holds instances to Cleaner, Cleaner only holds a phantom reference to the DirectBuffer (which is how it deallocates it).  Something had to be holding on to the DirectBuffer instances directly.

Re: [BUG] 2.8.1 Memory issues?
« Reply #5 on: October 24, 2011, 18:41:46 »
A small number of the DirectBuffers were at the root of the heapdump. I believe these correspond to the buffers I'm retaining for legitimate reasons.

The remainder are only referenced by the sun.misc.Cleaner instances, which are at the root of the heapdump. Note that the buffers that were created in the loop were being used as local vars. No reference was retained outside of the one method in which they were created.

I'll try to resurrect the 2.7.1 version to look for differences between the old and new. Maybe that will provide some insight into what's changed.

Steve