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 78AA5200B13 for ; Wed, 11 May 2016 06:57:42 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 774ED160A11; Wed, 11 May 2016 04:57:42 +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 C2421160A17 for ; Wed, 11 May 2016 06:57:41 +0200 (CEST) Received: (qmail 76317 invoked by uid 500); 11 May 2016 04:57:37 -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 75843 invoked by uid 99); 11 May 2016 04:57:36 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 May 2016 04:57:36 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 5E3A91A0B07 for ; Wed, 11 May 2016 04:57:36 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-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 mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id TaSWxOy7WCxj for ; Wed, 11 May 2016 04:57:35 +0000 (UTC) Received: from exsmtp14.agrinet.ch (exsmtp14.agrinet.ch [81.221.254.207]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id BE8C35FBA5 for ; Wed, 11 May 2016 04:57:34 +0000 (UTC) Received: from [192.168.1.2] ([194.191.233.117]) by imp02.agrinet.ch with id ssxZ1s0072YeanW03sxZZh; Wed, 11 May 2016 06:57:33 +0200 X-IMP-FROM: _________ X-IMP-AUTH_USERNAME: X-Original-IP: 194.191.233.117 Subject: Re: 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> <5732B6A6.2070703@span.ch> From: Alain Stalder Message-ID: <5732BBBC.9060905@span.ch> Date: Wed, 11 May 2016 06:57:32 +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: <5732B6A6.2070703@span.ch> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit archived-at: Wed, 11 May 2016 04:57:42 -0000 Also copied: PS: The source I just posted does not really work, the inner value can be garbage collected, so just posted as a "general idea" - not wanting to really dive fully into this I am better getting out now... ;) Alain On 11.05.16 06:35, Alain Stalder wrote: > 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 >