You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by oy...@apache.org on 2008/03/07 14:06:08 UTC
svn commit: r634658 -
/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/net/SocketConnection.java
Author: oysteing
Date: Fri Mar 7 05:06:08 2008
New Revision: 634658
URL: http://svn.apache.org/viewvc?rev=634658&view=rev
Log:
DERBY-3358: OOME at slave during replication
Make sure to reset objOutputStreamt in ReplicationMessageTransmit#writeObject before sending the new object. This removes the old object references both on the transmitter and the receiver side.
Contributed by Jorgen Loland.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/net/SocketConnection.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/net/SocketConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/net/SocketConnection.java?rev=634658&r1=634657&r2=634658&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/net/SocketConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/net/SocketConnection.java Fri Mar 7 05:06:08 2008
@@ -93,6 +93,8 @@
* stream.
*/
public void writeMessage(Object message) throws IOException {
+ // reset stream so that previously shipped objects can be gc'ed
+ objOutputStream.reset();
objOutputStream.writeObject(message);
//flush the stream to ensure that all the data that is part
//of the message object is written and no data remains
Re: svn commit: r634658 -
/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/net/SocketConnection.java
Posted by Øystein Grøvlen <Oy...@Sun.COM>.
Knut Anders Hatlen wrote:
> oysteing@apache.org writes:
>
>> Author: oysteing
>> Date: Fri Mar 7 05:06:08 2008
>> New Revision: 634658
>>
>> URL: http://svn.apache.org/viewvc?rev=634658&view=rev
>> Log:
>> DERBY-3358: OOME at slave during replication
>
> Isn't this DERBY-3497?
Oops. I will fix that.
>
>> public void writeMessage(Object message) throws IOException {
>> + // reset stream so that previously shipped objects can be gc'ed
>> + objOutputStream.reset();
>> objOutputStream.writeObject(message);
>> //flush the stream to ensure that all the data that is part
>> //of the message object is written and no data remains
>
> Wouldn't it be better to call reset after writeObject() (and before
> flush())? That would allow both the sender and the receiver to reclaim
> the memory earlier.
>
I guess the way this stream works, we might as well call reset right
away. As far as I understand, before reset is called, when writing more
objects to the stream that have references to objects already written to
the stream since last call to reset, it will not lead to those objects
being serialized again. Since each replication message will be
independent of earlier messages, there is no need for sharing objects
and the stream could be reset right away.
A possible alternative, if I interpret the javadoc for
ObjectOutputStream correctly, would be to use writeUnshared instead of
writeObject. Since the written object will not be shared, maybe calling
reset would not be necessary in that case.
--
Øystein
Re: svn commit: r634658 -
/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/net/SocketConnection.java
Posted by Knut Anders Hatlen <Kn...@Sun.COM>.
oysteing@apache.org writes:
> Author: oysteing
> Date: Fri Mar 7 05:06:08 2008
> New Revision: 634658
>
> URL: http://svn.apache.org/viewvc?rev=634658&view=rev
> Log:
> DERBY-3358: OOME at slave during replication
Isn't this DERBY-3497?
> public void writeMessage(Object message) throws IOException {
> + // reset stream so that previously shipped objects can be gc'ed
> + objOutputStream.reset();
> objOutputStream.writeObject(message);
> //flush the stream to ensure that all the data that is part
> //of the message object is written and no data remains
Wouldn't it be better to call reset after writeObject() (and before
flush())? That would allow both the sender and the receiver to reclaim
the memory earlier.
--
Knut Anders