Hi. I am using Java 8 update 101 64 bit
I wrote a simple program that adds dummy data into XMLWriter. After execution of the program I expect the memory to be released. But it is not. It remains.
public static void writeSimpleElement(String elementName,
String elementValue,
XMLStreamWriter writer) throws XMLStreamException
{
writer.writeStartElement(elementName);
writer.writeCharacters(elementValue);
writer.writeEndElement();
}
public static void main(String[] args) throws PSException, XMLStreamException, IOException {
XMLOutputFactory factory = XMLOutputFactory.newInstance();
ByteArrayOutputStream o = new ByteArrayOutputStream();
GZIPOutputStream outputStreamZip = new GZIPOutputStream(o);
XMLStreamWriter writer = factory.createXMLStreamWriter(outputStreamZip, "UTF-8");
writer.writeStartElement("dataSet");
///////////////////////////////////
for (int i=0;i<80000;i++)
{
String elementName = "timesheet";
writer.writeStartElement(elementName);
System.out.println(i);
writeSimpleElement("kx"+i, i+"", writer);
writeSimpleElement("kkx"+i, i+"", writer);
writer.writeEndElement();
}
writer.writeEndElement();
writer.writeEndDocument();
writer.flush();
writer.close();
outputStreamZip.flush();
outputStreamZip.close();
outputStreamZip = null;
writer = null;
byte [] res = o.toByteArray();
o.flush();
o.close();
res=null;
factory=null;
Scanner scanner = new Scanner(System.in);
String username = scanner.next();