+ Start a Discussion

New dom.Document class and heap usage

 Has anyone used the new dom.Document class?  


            HTTPResponse res = http.send(req);
            dom.Document doc = res.getBodyDocument();


I am using it to fetch the xml response from a web service.  But it looks like it uses a lot of heap space.  Based on logging using Limits.getHeapSize, I see the following:


before http callout: 1380 bytes

right after HTTPResponse res = http.send(req): 902657 bytes

right after res.getBodyDocument(): 2999340 bytes (and it bombs out because it exceeded the 2Mb heap limit).


The response size coming back from the web service is a little under 900Kb (based on the raw response as recorded in SOAPUI).   Is it normal for getBodyDocument to produce a DOM object that is 2+ times the size of the raw response?