Re: Proxies and PermGen

53 views
Skip to first unread message

kbwelker

unread,
Nov 2, 2012, 1:58:26 PM11/2/12
to Funcito
Excellent question. While I have not performed any formal study on
Perm Gen space usage, I put in two safeguards to help limit it. As
you asked, I have indeed put a cache in place for proxy classes, so
that as additional proxies are requested they first look in the
cache. Secondly, I have given the user the option to reuse instances
of the proxies multiple times, to wrap multiple methods using the same
proxy instance. This second mechanism really provides no advantage
over the first since the cache is always in place. But it does
provide brevity of expression, and if caching were to be eliminated or
optional in the future there would still be this means of limiting
Perm Gen exhaustion.

Thanks for the question.

-- Kervin

On Nov 2, 6:38 am, Alexey Frishman <alexey.frish...@gmail.com> wrote:
> Hi dear authors!
>
> I find your library amazing and I want to use it in my projects.
>
> My only concern is about Perm Gen space limit. I know that usually every
> new proxy class is created in Perm Gen space. Also I know that very
> extensive usage of proxies causes hitting the limit of Perm Gen space and
> OutOfMemoryError as result. Have you tried to test, how much memory is
> consumed, while using the library? Is new class in Perm Gen created every
> time I call corresponding method from the library, or those classes are
> created only first time for some functional signature and all the next
> times they are only taken from cache?

Alexey Frishman

unread,
Nov 2, 2012, 7:40:37 PM11/2/12
to fun...@googlegroups.com
I'm very glad you did not miss this important problem and payed special attention to it. Thanks for your explanation, I will definitely give your library a try. But first of all I think of doing some kind of heavy-load testing for the library and see how it behaves in case we call the same method thousands/millions times. Once done, I will get back with my results.

In general, I think your library must have been a standard for Java applications. At least it could be part of Guava. I really wonder, why so few people know/use this approach, while for me it was always looking very appealing.

kbwelker

unread,
Nov 2, 2012, 9:31:40 PM11/2/12
to fun...@googlegroups.com
Thank you for the high praise. I quickly realized that this project was outside of the charter of Guava, which actually allowed me to develope it to support multiple APIs in addition to Guava.

Also, while I did not measure the Perm Gen usage under load, I do in fact have performance benchmarks checked in the repository. I use them currently only to measure the relative impact of changes I make, but you might think about looking at those, and perhaps executing them in your target environment.

kbwelker

unread,
Nov 5, 2012, 4:33:46 PM11/5/12
to Funcito
Additional notes: I deliberately micro-benchmarked only the execution
of function-like objects, and not their construction, as I supposed
Functions (predicates, etc.) will generally be created once and
executed many times. Also, while I only benchmark Guava Functions,
the metrics should be equally applicable for Guava Predicate or any of
the other supported APIs. That is because the benchmarks demonstrate
the relative performance of:
1. ordinary method calls vs
2. anonymous inner class Functions around those methods vs
3. Funcito Functions.
And the overhead is exactly identical regardless of the API that is
being used. So simply benchmarking Guava Function was sufficient.
The benchmarks also compare differences between using:
1. cglib vs
2. Javassist vs
3. native Java dynamic proxies
as the proxy source.
Reply all
Reply to author
Forward
0 new messages