I think the question belongs to Web services,
SOAP ... forum but I do not think I am authorized to move this question to that
thread.
First, I wish your question were little clearer; "which runs out of memory very frequently..." What runs out of memory? WAS? your code? What do you get out of memory error?
There are many reasons why this might happen:
[1] Your machine does not have enough RAM. WAS 4.0 recommends 512 MB I believe. If you are using windows, go Start > All programs > Accessories > System Tools > System Information
[2] You did not allocate enough memory to JVM. There is way to allocate memory to WAS. You have to specify some command line arguments to increase the memory it uses. Do some research on how to set this.
[3] Your code consumes a lot of memory quickly enough that the garbage collector cannot reclaim the memory.
It might help if you could post the stack trace here.