Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-18534

Propose a mechanism to free the direct memory occupied by RPC Connections

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • rpc-server
    • None

    Description

        In the RPC Client, a thread called RpcRequestSender is responsible for writing the connection request to the socket. Every time a request is sent, a direct memory is applied for in sun.nio.ch.IOUtil#write() and cached.

        If Connection and RpcRequestSender are promoted to the old generation, they will not be recycled when full gc is not performed, resulting in the DirectByteBuffer cached in sun.nio.ch.Util not being recycled. When the memory occupied by DirectByteBuffer is too large, the jvm process may not have the opportunity to do full gc and is killed.

        Unfortunately, there is no easy way to free these DirectByteBuffers. Perhaps, we can manually free these DirectByteBuffers by the following methods when the Connection is closed.

      private void freeDirectBuffer() {
        try {
          DirectBuffer buffer = (DirectBuffer) Util.getTemporaryDirectBuffer(1);
          buffer.cleaner().clean();
        } catch (Throwable t) {
          LOG.error("free direct memory error, connectionId: " + remoteId, t);
        }
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            xinqiu asdfgh19
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: