2012-11-03 4 views
3

Possible en double:
What is the actual memory place for static variables?des variables d'instance statiques

D'où vient les variables d'instance statique définie dans une classe sont stockés - en tas ou dans la production permanente?

JLS (deux pré Java SE 7 et Java SE 7) dit que:

17.4.1 Shared Variables 
Memory that can be shared between threads is called shared memory or heap 
memory. 
All instance fields, static fields and array elements are stored in heap memory. 

MAIS this post dit que:

Success Metrics 
... 
Class metadata, interned Strings and class static variables will be moved from the permanent generation to either the Java heap or native memory. 
... 

Description 
... 
Class metadata and statics are allocated in the permanent generation when a class is loaded and are garbage collected from the permanent generation when the class is unloaded. Interned Strings are also garbage collected when the permanent generation is GC’ed. 
... 

Selon ci-dessus statics Posteurs sont dans la zone de production permanente.

Lequel est correct?

+2

serait JLS mensonge: P ?? – PermGenError

Répondre

1

dans l'article

une partie du tas Java appelée la génération permanente

de sorte génération permanente est en tas.