Not sure I am following you. Which of the billion instances do u want to eliminate?
You could write a small piece of code to intern objects yourself, but since you also have a field you need to mutate you need to think carefully how u are going to manage mutation and sharing. (Interning is fairly well understood for Java-like languages -- u can start with http://stackoverflow.com/questions/7035659/good-pattern-for-creating-an-object-that-supports-interning ) On 10/19/14, 8:48 AM, WangChen wrote: > Hi, > > I have a class named Data and it has some basic field like this: > > class Data { > val i:Int; > val j:Int; > var flag: Boolean; > var value: Int; > // other fields and methods > } > > My program will create many instances of Data, lets say 1 billion, which will > cost a lot of memory since every instance need extra spaces. > > And i can’t use structs here because they are immutable but i need to update > fields of it. > > So what can i do here ? > Is there a way to manage memory explicitly? > > > > > ------------------------------------------------------------------------------ > Comprehensive Server Monitoring with Site24x7. > Monitor 10 servers for $9/Month. > Get alerted through email, SMS, voice calls or mobile push notifications. > Take corrective actions from your mobile device. > http://p.sf.net/sfu/Zoho > _______________________________________________ > X10-users mailing list > X10-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/x10-users ------------------------------------------------------------------------------ Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users