ObjectInputStream$HandleTable$HandleList

J

Jeff

In the course of struggling with a bug, a data structure that I don't know
about showed up as the largest instance count. Can someone give me a bit
of background on this structure?

Briefly, my client receives objects by reading an object input stream.
After a few thousand objects, the client experiences a java.stack overflow.
I have gotten a stack trace that indicates it's the deserialization process
causing the stack overflow. There's lots written on serialization and the
stack, but I haven't been able to fix the bug.

I used OptimizeIt to profile the client:
* int[] had the largest instance count.
* java.io_ObjectInputStream$HandleTable$HandleList had the second largest
instance count at 143579 before the stack overflow.

3 questions:
1. What's the HandleList? Should it grow so large?
2. Is there an int array associated with it?
3. If the heap gets too large, shouldn't it throw a outOfMemory error? Or
could my heap being running into my stack?

CLIENT CODE
Socket sock = new Socket( ipAddress , port );
is = new ObjectInputStream( sock.getInputStream() );

while (true) {
Object result = (Object) is.readObject();
// other processing
}


SERVER CODE
ServerSocket serverSock = new ServerSocket(port);

sock = serverSock.accept();

while (true) {
os = new ObjectOutputStream( sock.getOutputStream() );
os.writeObject( outboundObject );
os.reset();
os.flush();
}

Thanks
 
J

John C. Bollinger

Jeff said:
In the course of struggling with a bug, a data structure that I don't know
about showed up as the largest instance count. Can someone give me a bit
of background on this structure?

Briefly, my client receives objects by reading an object input stream.
After a few thousand objects, the client experiences a java.stack overflow.
I have gotten a stack trace that indicates it's the deserialization process
causing the stack overflow. There's lots written on serialization and the
stack, but I haven't been able to fix the bug.

I used OptimizeIt to profile the client:
* int[] had the largest instance count.
* java.io_ObjectInputStream$HandleTable$HandleList had the second largest
instance count at 143579 before the stack overflow.

3 questions:
1. What's the HandleList? Should it grow so large?
2. Is there an int array associated with it?
3. If the heap gets too large, shouldn't it throw a outOfMemory error? Or
could my heap being running into my stack?

From the API docs for StackOverflowError: "Thrown when a stack overflow
occurs because an application recurses too deeply." This probably means
that the object the client is deserializing has a fiendishly complex
graph. I interpret the instance count of HandleList to support this
theory, although I am not specifically familiar with it. Your JVM may
have an option to increase the size of the runtime stack (Sun's does),
which could make the problem disappear, at least for now. In the long
run, you should consider whether there are ways to restructure your
classes or algorithm so that simpler objects can be transported. We
probably could offer some advice on that if you told us something about
the classes involved.


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top