You should be able to come up with some middle ground number for your buffers - sending one byte at a time is obviously bad, and so is allocating the entire 900K buffer.

Using a send buffer around 8K to 16K should work pretty well. My guess is that you need to do Base64 encoding on the fly - in that case, you can tweak input chink size to that there is no padding at the end of encoded data (the "==") and the next encoded chunk seamlessly fits at the end of the previous one.

Finally, where does the string come from? If it comes from a file, you should not read the whole thing at once.

-- Kostya

23.09.2010 19:54, TheSeeker пишет:
I have reduced lenght of byte to 250 000 (byte[] array = new
byte[250000] instead of char huge char[] array = new char[900000] )

I've been trying sending string instead of character by character. if
string is big (250 000 characters aprox and 250 Kbytes) de Garbage
collector go crazy and the time spend is too much (more than 2 min and
it is funny). Then i do other experiment, split the string in a lot of
little string of lenght of 1024 bytes and 256 bytes. The conclusion is
if string is huge the time is infinite and CG produce the spend of
time, and when the string is small 256bytes GC seem to do not produce
the problem. In the extreme case when i send byte by byte (Log posted
above) is the best case

In the original problem is the best case, because GC spent 1,2 seg(150
ms*8) aprox but my chronometer in my hand said 15 seg.

This is rare for me because if i send byte by byte i will be sending a
header of TCP/IP about 40bytes. If i send byte by byte i will be
sending 40*(1Mbytes of info) = 40Mbyes and it work better than send
1Mbyte in a string

On Sep 10, 12:53 am, Miguel Morales<[email protected]>  wrote:
No, breaking it into two arrays will not help you.
I haven't done this myself, but I THINK what you'll want to do is use
a BufferedWriter  or something similar.  In any case, you'll HAVE to
buffer your data and send it in chunks.  HTTP supports this quite
well.  Take a look at some BufferedWriter tutorials, or perhaps
someone can suggest a better approach.



On Thu, Sep 9, 2010 at 9:41 PM, TheSeeker<[email protected]>  wrote:
yes, i had a mismach, thanks. But i still have the same problem with
time(1 min ) and GC. Create 2 or more array instead of the big one
will solve the problem with time?
On Sep 8, 5:47 pm, Frank Weiss<[email protected]>  wrote:
Looks bad, very bad.
First, I have no idea why you're allocating 1.8 MB (remember that Java, and
I suppsoe Dalvik as well, takes 16 bits per char). How come so much? Second,
of course writing a byte (or is it a char, there's a mismatch there) is
going to be slower than writing at least a few thousand at a time.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
~ Jeremiah:9:23-24
Android 2D 
MMORPG:http://developingthedream.blogspot.com/,http://diastrofunk.com,http://www.youtube.com/user/revoltingx


--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to