This week's book giveaway is in the Programmer Certification forum. We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hi, I have asked Vector and Hashtable in coding.When it was tested in server, admin people said that Vector and HashTable are taking more memory.So try to reduce it.My question is If i use HashTable.clear() and Vector.clear().I know that it will clear all elements from Vector and HashTable, does it releases the consumed space from memory also. Thnks in Adv. Senthil
Hi, Instead of Hashtable and Vector ,u can use HashMap and ArrayList respectively...When you use hashtable and vector ,it will take extra memeory as it would require some resource for synchronozation.If u dont really want synchronization in your code ,you can go for HashMap and ArrayList.. A.Umar
Sun Certified Java Programmer for Java 2.0 (93%) <p>----Winners always make the learning a habit
I think we need to know a little more about how you are using Hashtable and Vector. When correctly used, these objects themselves don't usually take up much space compared with the objects "inside" them. Most memory problems I have encountered seem to be because too many objects are being created and then abandoned. The Garbage Collector just has trouble keeping up. Both Hashtable and Vector allow a "guess at the size" parameter to the constructor, and both can slow down and gobble memory when they discard one set of data to move to a bigger one if you grow them a lot without pre-allocating a reasonable amount of space. Could this be the problem ?
Memory isn't a big issue with Hashtable and Vector vs. HashMap and ArrayList however overall performance is. Since the former are synchronized unless you need them to be you are incurring a huge performance hit if they are accessed by multiple threads. Kevin
You guys wanna see my fabulous new place? Or do you wanna look at this tiny ad?
Gift giving made easy with the permaculture playing cards