Could top-notch features in Scala be interested in allocating a large Perming space in the JVM?

As for the first-class features in Scala, it is written in the book Programming by Scala:

A function literal is compiled into a class, which when created at runtime is the value of the function.

When there are a lot of first-class features in the program, will this affect the PermGen JVM space? because instead of simple functions, the compiler generates classes for each variation of the function value (for example, in the case of various definitions of partially applied functions).

+4
source share
3 answers

The memory profile will certainly differ from the profile of regular Java programs, although you can configure almost any memory parameter on the JVM.

All I can say, however, is that in one year of deep participation in the Scala community, I have never seen anyone complain about it.

+3
source

I have no reason for this, but I feel that if you are writing some kind of non-trivial program, the amount of space occupied by your "real" data will significantly reduce the amount of space occupied by a few additional definitions of the function as a class.

In other words, I would not worry about that.
+2
source

This is a proven mathematical fact that the number of classes that you generate using first-class functions can asymptotically approach, but never exceed, the number of compiled classes in the full Spring distribution. Do not worry, these pioneers will deal with Perm problems first!

+1
source