Release Memory used by Webservice

D

David Hanson

All,

I have an application which a has a main Form which child forms are opened
from, then once the user has finished using the opened form it is closed and
disposed. All of the application worked fine until I started to plug some
webservices into my code. What I found was that the applications memory
usuage started to rocket, the application slowed down and things went pants.

I started to look at the new fuctions which included webservices. The
example below shows one of these fucntions.

Public Function UploadData() As Boolean
UploadData = False
Dim sPath As String = BlogPath
Dim oData As New DataSet
Dim oRows As DataRow()

With oData
.ReadXml(sPath)
oRows = .Tables(0).Select("Uploaded = false") '
.Tables(0).Rows.Clear()
.Tables(0).Rows.Add(oRows)
End With
Dim oWs As New CodeBehind.ApplicationLogic
oWs.Credentials = GetCredentials()

If oWs.UpdateData(oData, AppMod.OUser.UserID.ToString) <> "" Then
Return False
End If

oData = Nothing
oWs = Nothing
UploadData = True
End Function


Then debugging through my app I started to monitor how much memory was used.
What I found was this:

Function Started at 93844 Bytes
..ReadXml(sPath) line raised memory to 143032 Bytes
oWs.UpdateData line raised memory to 235752 Bytes.

The problem I have here is that I can never seem to release the memory used
by calling the webservice method. If i go on to call other webmethods in
other functions the memory is rapidly eaten up. I tried many things to
resolve this like GC.Collect and disposing forms but none of them seem to
work. I had a single instace of the webservice objedct held in an an
application module but the same problem occurs?

Can anyone help me on this? This is running on CF for the Smartphone by the
way....

Regards

Dave Hanson
 
A

Anatoly

I haven't had to deal with a problem like that, but would you consider
bringing out the
Dim oWs As New CodeBehind.ApplicationLogic
oWs.Credentials = GetCredentials()

Into the class scope? and just call these two once. May be the instantiation
of the service leaves some things hanging, so this should just keep it to 1
time.

Anatoly
 
D

David Kline [MSFT]

Using Anatoly's suggestion of creating the service object once (class
scope) will boost your performance immensely. The very first web method
call on a service takes a performance hit. Subsequent calls on the same
service object (to any web method) will be significantly faster.

I would not be suprised if this was the problem (and not the application's
memory usage).

Thanks!
David Kline
Microsoft .NET Compact Framework
--------------------------------
This posting is provided “AS IS” with no warranties, and confers no
rights.

Please do not send email directly to this alias. This alias is for
newsgroup purposes only. To correspond with me directly, remove the
'online' from
my alias.
 
D

David Hanson

I decided to chaneg the whole comminication methodology and migrated to
Sockets using TCP.

It is as far as I can tell the only realy option for Smartphone developers
wen trying to upload data to servers. The webservices are just to slow and
verbose.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top