PPC DIME Web Service ... Weird behavior :O

  • Thread starter Thread starter Lisa
  • Start date Start date
L

Lisa

Hi, I have a web service that uses DIME to send and receive files between
pockrt pc and server. I have noticed very odd behavior. If I call the web
service from a button click event it works the first time. However, if I
click the button a second time it does not work. I get an "Out of memory"
error on the pocket pc when the code tries to create a new stream.



This is where it gets odd... I can get it to work every time but I first
have to switch to a different screen like the Today screen or Settings
screen then return to my app screen and click the button.



This seems like a garbage collection issue where the streams memory is not
being released by the garbage collector, unless I switch to another screen.



Anyone got an idea what can be done to correct this?



Thanks ;)
 
Hi Lisa,

I don't know what DIME is, but I'll assume its a webservice as stated.

If you are sending or receiving large pieces of data, it is best to read the data in by chunks of 1024 bytes. It sounds like you might be allocating memeory for the full size of the file (e.g. byte[] file_bytes = new byte[file.Length]). Don't do it this way, but rather once the stream writer is open, read in chunks of 1024 and write the bytes to the stream.

This is the same behavior you should use for reading off a ResponseStream as well. Write the bytes read to the disk as you read it off the stream rather than allocating an array of file.Length.

You might want to check up on either of these scenarios.

~~K
kzgrey(AT)ntplx(DOT)net
 
Back
Top