Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 37284200AE4 for ; Wed, 11 May 2016 06:35:57 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 35D04160A11; Wed, 11 May 2016 04:35:57 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 815CE16098A for ; Wed, 11 May 2016 06:35:56 +0200 (CEST) Received: (qmail 39224 invoked by uid 500); 11 May 2016 04:35:55 -0000 Mailing-List: contact dev-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list dev@groovy.apache.org Received: (qmail 39204 invoked by uid 99); 11 May 2016 04:35:55 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 May 2016 04:35:55 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 1186418056C for ; Wed, 11 May 2016 04:35:55 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.28 X-Spam-Level: X-Spam-Status: No, score=0.28 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id Tfu47_N6MabT for ; Wed, 11 May 2016 04:35:53 +0000 (UTC) Received: from exsmtp14.agrinet.ch (exsmtp14.agrinet.ch [81.221.254.207]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTP id 9E3505F4ED for ; Wed, 11 May 2016 04:35:52 +0000 (UTC) Received: from [192.168.1.2] ([194.191.233.117]) by imp02.agrinet.ch with id ssbr1s0052YeanW03sbr0R; Wed, 11 May 2016 06:35:51 +0200 X-IMP-FROM: _________ X-IMP-AUTH_USERNAME: X-Original-IP: 194.191.233.117 Subject: Re: To ClassValue or not to ClassValue: That is the question! To: dev@groovy.apache.org References: <572ECD0B.1070808@span.ch> <5730460C.608@gmx.org> <5730FE62.6050807@span.ch> <57310DDF.1030104@span.ch> <57311149.1080607@span.ch> From: Alain Stalder Message-ID: <5732B6A6.2070703@span.ch> Date: Wed, 11 May 2016 06:35:50 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <57311149.1080607@span.ch> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit archived-at: Wed, 11 May 2016 04:35:57 -0000 Copied from my comment at https://issues.apache.org/jira/browse/GROOVY-7591 (partially in response to what Craig added there yesterday): To me the ideal solution would be to drop the "groovy.use.classvalue" system property in Groovy 2.4.7, to always use ClassValue (with Java 7 and later), but to give the Java VM a ClassValue that it can garbage collect already without a JVM fix. Why drop the system property: The matter is complex enough, maintaining more variants than absolutely necessary should be avoided. Why not wait for a fix in the Java VM: Because even if/when it comes to Java 9/8/7, it will still require people to upgrade their VMs which is not a given at all. Here is a first attempt to resolve this as simply as possible in principle: A modified version of the test sources that were submitted with the Java VM bug report. I am simply wrapping the MyClassValue class with another instance of ClassValue that only has weak references to the MyClassValue instance. This worked on Java 7 and 8. With Java 7 I saw used PermGen rise close to the configured maximum and then it was collected. With Java 8, Metaspace did not even rise, which is important because by default there is no maxium set for Metaspace. -- See https://issues.apache.org/jira/browse/GROOVY-7591 for Java sources -- I wrap the classes resulting from compiling MyClassValue and MyClassValueWrapper into t/t.jar and then run the test with "java -ea -XX:MaxMetaspaceSize=64m -cp . CVTest" resp. "java -ea -XX:MaxPermGenSize=64m -cp . CVTest". I know that there is already much more specific work going on with regard to fixing these issues and there might be more issues with garbage collecting classes in the Groovy code - I just wanted to say that it might be good to strive for a solution with minimal complexity. PS: I hope it is OK to copy this, when I post here, code gets broken up with line breaks, making it possibly harder to read/try out, on the other hand that issue seems like maybe not the ideal place to discuss the issue? Alain