You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/08/24 19:09:20 UTC

[GitHub] [lucene-solr] uschindler commented on pull request #1779: LUCENE-9478: Prevent DWPTDeleteQueue from referencing itself and leaking memory

uschindler commented on pull request #1779:
URL: https://github.com/apache/lucene-solr/pull/1779#issuecomment-679311573


   This is a limitation of the Java Compiler javac. Whenever you access an instance field from a class (final or not doe snot matter), it created a lamda bount to this. The lambda method then does a getfield and invokes method. Here is the Bytecode of the lambda before this change:
   
   ```
     private long lambda$advanceQueue$1();
       Code:
          0: aload_0
          1: getfield      #20                 // Field nextSeqNo:Ljava/util/concurrent/atomic/AtomicLong;
          4: invokevirtual #75                 // Method java/util/concurrent/atomic/AtomicLong.get:()J
          7: lconst_1
          8: lsub
          9: lreturn
   ```
   
   As you see it's a non-static method. The generated lambda therefor has a reference to this (methodhandle bound to `this`).
   
   After your patch, the lambda is static:
   
   ```
     private static long lambda$getPrevMaxSeqIdSupplier$1(java.util.concurrent.atomic.AtomicLong);
       Code:
          0: aload_0
          1: invokevirtual #75                 // Method java/util/concurrent/atomic/AtomicLong.get:()J
          4: lconst_1
          5: lsub
          6: lreturn
   ```
   
   The generated anonymous class will have just bw bound tothe AtomicLong and not `this`.
   
   By analyzing the code we see that issue is fixed, test is not necessarily needed, but it's hard to check the bytecode :-)
   
   +1 for the fix!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org