I did it, but now i have a problem with garbage collector on android
(GC freed) and the time spend it on send a big string(array of char)
to a server
Here code snippet

xm1,xm2a,xm2b,xm4,xm5,xm6 are String of Java, array is an array of
char huge char[] array = new char[900000]
                                        try{
                                                Log.i("Android","before DOS");
                                                out = new 
DataOutputStream(s.getOutputStream());
                                                Log.i("Android","later DOS");
                                                Log.i("Android","write xm1 
xm2");
                            out.writeBytes(xm1);
                            out.writeBytes(xm2a);

                            Log.i("Android","writeByte BigString 1");
                            for(int a =0;a<nc;a++){
                                out.writeByte(array[a]);
                            }

                            //out.writeBytes(xm3);
                            Log.i("Android"," End writeByte BigString
1");
                            out.writeBytes(xm4);
                            out.writeBytes(xm2b);
                            Log.i("Android","writeByte BigString 2");

                            for(int a =0;a<nc;a++){
                                out.writeByte(array[a]);
                            }

                            //out.writeBytes(xm3);
                            Log.i("Android","End writeByte BigString
2");
                            out.writeBytes(xm4);
                            out.writeBytes(xm5);
                            out.writeBytes(xm6);
                            Log.i("Android","END writeByte xm4 5 6");

                                        }
                                        catch(Exception e0){
                                                e0.printStackTrace();
                                        }

The logCat(DDMS view) said

09-08 16:41:26.677: INFO/Android(1926): before DOS
09-08 16:41:26.687: INFO/Android(1926): later DOS
09-08 16:41:26.687: INFO/Android(1926): write xm1 xm2
09-08 16:41:26.687: INFO/Android(1926): writeByte BigString 1
09-08 16:41:29.257: DEBUG/dalvikvm(1926): GC freed 35034 objects /
902128 bytes in 175ms
09-08 16:41:31.187: DEBUG/dalvikvm(227): GC freed 106 objects / 53400
bytes in 192ms
09-08 16:41:32.247: DEBUG/dalvikvm(1926): GC freed 39530 objects /
949520 bytes in 175ms
09-08 16:41:34.907: DEBUG/dalvikvm(1926): GC freed 37157 objects /
892248 bytes in 178ms
09-08 16:41:37.587: DEBUG/dalvikvm(1926): GC freed 37157 objects /
892248 bytes in 166ms
09-08 16:41:40.277: DEBUG/dalvikvm(1926): GC freed 37157 objects /
892248 bytes in 173ms
09-08 16:41:42.927: DEBUG/dalvikvm(1926): GC freed 37157 objects /
892248 bytes in 165ms
09-08 16:41:45.587: DEBUG/dalvikvm(1926): GC freed 37157 objects /
892248 bytes in 174ms
09-08 16:41:47.587: INFO/Android(1926):  End writeByte BigString 1
09-08 16:41:47.587: INFO/Android(1926): writeByte BigString 2
09-08 16:41:48.247: DEBUG/dalvikvm(1926): GC freed 37146 objects /
892064 bytes in 170ms
09-08 16:41:50.907: DEBUG/dalvikvm(1926): GC freed 37149 objects /
892064 bytes in 173ms
09-08 16:41:53.537: DEBUG/dalvikvm(1926): GC freed 37149 objects /
892064 bytes in 165ms
09-08 16:41:56.187: DEBUG/dalvikvm(1926): GC freed 37149 objects /
892064 bytes in 174ms
09-08 16:41:58.807: DEBUG/dalvikvm(1926): GC freed 37149 objects /
892064 bytes in 165ms
09-08 16:42:01.547: DEBUG/dalvikvm(1926): GC freed 37149 objects /
892064 bytes in 179ms
09-08 16:42:04.197: DEBUG/dalvikvm(1926): GC freed 37149 objects /
892064 bytes in 169ms
09-08 16:42:06.867: DEBUG/dalvikvm(1926): GC freed 37149 objects /
892064 bytes in 180ms
09-08 16:42:08.357: INFO/Android(1926): End writeByte BigString 2
09-08 16:42:08.367: INFO/Android(1926): END writeByte xm4 5 6

Also i have read
http://developer.android.com/guide/practices/design/performance.html
I am using char[] array = new char[900000]; and i know it has the
fault of iniciate de CG, but actually i dont know how to store
a lot of data...maybe store in a file in SD card?(but access to sd-car
can be slow too)...maybe not...any idea to deal with GC??

I will probe WITHOUT for(int a =0;a<nc;a++), and it is fast, very
fast(1 seg or less).
WITH for(int a =0;a<nc;a++) it take 1:22 minutes(client side)


On Aug 30, 7:14 pm, TheSeeker <[email protected]> wrote:
> Hi
> I am trying to send a string to server, i would like to know how many
> alternatives i have. Actually i am using a socket but i don't know if
> there is a better option.
> The string is big(lenght about 192000 , yes too much 192000), i think
> is a little is stupid try to do this, but the server works with
> sending a string to one computer to other computer and my mision is to
> make a conection between a computer like server with a client (android
> phone). If i can send i big string so i do not need to change the
> program on the server.
> I need info about how to send a string with
> 1. GPRS EDGE
> 2. Wi-FI

-- 
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