Jonathan Avraham wrote:
> Hi All,
>
> I am running under Windows OS and UNIX, in both cases the files are
> not delet ed but in UNIX theyare free to be deleted where as in
> Windows they are locked until the tomcat service is stopped.
>
> I have tried your suggestion, first of all I must say that the
> SOAPMessage object is terminated at the end of the scope it is defined
> in so setting it to null is redundant. I tried forcing the gc after
> the scope ended, indeed the file was deleted.
>
> There is a bit of problem here, the gc is automatically performed when
> there is low memory available in the heap, however the temp file
> deletion is a hard drive space issue. The two do not correlate and
> this causes my drive to fill up.
>
OK as jitu pointed out i would fix the code to call MimePart.close()
whenever you clear the contents of the attachment part. Would that work
for you.
regards,
kumar
> Thanks,
> Jonatan
>
> On Fri, Jan 15, 2010 at 9:38 AM, Kumar Jayanti
> <Vbkumar.Jayanti_at_sun.com <mailto:Vbkumar.Jayanti_at_sun.com>> wrote:
>
> Hi Jonathan,
>
>
> Kumar Jayanti wrote:
>> Hi Jitu,
>>
>> Jonathan Avraham wrote:
>>> Hi,
>>>
>>> I am using SAAJ 1.3.4 with mimepull enabled for large attachment
>>> support.
>>> I am using getRawContent() from the attachment , I then proceed
>>> to extract what I need from the Inputstream.
>>> The problem is that the temp file created for the message is not
>>> deleted and still kept open by the system, this means I can't
>>> even delete it manually until I restart tomcat.
>>> I have tried closing the Inputstream, clearing the content from
>>> the attachment and clearing the hole SOAPMessage, nothing worked.
>>>
>>> What am i doing wrong?
>>>
>> I have obviously missed some step to clean up the temp files
>> created by MimePull in my usage of the API in SAAJ. Can you tell
>> me how we can cause the MimePull runtime to delete temp-files ?.
> The SAAJ MessageImpl class holds onto the MimePullMultipart
> which inturn holds the individual Mime Parts. So what did you mean
> by clearing the whole SOAPMessage. Make sure you are setting all
> reference's to the message in your application to null.
>
> //application code
> SOAPMessage message = ....
> //code that uses the messages, reads attachments etc
> //release the reference to the message
> message = null;
>
> If this still does not cleanup the temp files (after sometime)
> then i believe i will need to talk to the MimePull lead and get
> back.From looking at the code of MimePull, it appears they make
> use of WeakReference to a DataFile. Try to force a GC cycle and
> see if that clears it up. Are you running on Windows OS ?.
>
> I would need feedback from you on whether any of this helps so i
> can update the blog post. I will also try to experiment the
> condition that you are seeing but i will get to it next week.
>
> As far as i can see if you call clearContent() on an
> AttachmentPart the code clears the MimePart that it is holding
> onto so this is definitely not a problem.
>
>
> regards,
> kumar
>
>