0

If string pool caches the string values then till what time it keeps values into the memory. When it sends those values to GC. If I send two call request of a same REST web service then Does this two separate web service requests uses same memory from the string pools for the string variables used inside the web service. (Consider there is only one app server where web service call is going)

  • 1
    *"If string pool caches the string values"* - it doesn't – apangin May 22 '21 at 12:17
  • Thanks for reply but caches I mean to say keeping the value inside the string pool (heap memory area) during the creation of string variable in program. – praveen kumar May 22 '21 at 12:26
  • 4
    Almost every phase you’re using (“sends those values to GC”, “memory from the string pools”, “creation of string variable”) is demonstrating a wrong understanding of how things actually work. But the strongest indicator is that you’re thinking that those things mattered. They don’t. Let the runtime do its work and move on. Come back to us when you have a real problem. – Holger May 25 '21 at 08:05
  • Thank you for reply. I was facing one problem in web service. Actually, I wanted to use same string value (same instance from memory) inside two different web service calls. Meanwhile, I have achieved it through another way now. I found my answer for garbage collection inside the post https://stackoverflow.com/questions/18406703/when-will-a-string-be-garbage-collected-in-java – praveen kumar Jun 15 '21 at 02:51

0 Answers0