JDK-8236414 : stringStream allocates on both ResourceArea and C-heap
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 15
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2019-12-20
  • Updated: 2020-08-19
  • Resolved: 2020-08-04
Related Reports
Relates :  
Relates :  
Description
stringStream implements ResourceObj and thus new() places it on the ResourceArea. The char* containing the printed content is allocated on the C heap. 

It is not desireable to allocate the char*  on the ResourceArea as if it is resized under a deeper ResourceMark than that of the stringStream, the char* will be invalidated when leaving that deeper ResourceMark's scope.  This led to various errors before.

On the other side the fact that the destructor of stringStream must be called after allocating it with new() to free the char*, but delete() is not necessary/possible, is unexpected.

 
Comments
Runtime Triage: This is not on our current list of priorities. We will consider this feature if we receive additional customer requirements.
04-08-2020