开发者

remote Actor doesn't work on Android -> stack overflow

I'm currently testing remote actors on Android. I have done a small program with two classes: the first implements the main activity and the second implements an actor.

When I create my actor, the program is killed with this message : stack overflow on call to Ljava/lang/throwable... for some reason, the stack of the program seems to be too small (or there is some kind of bug) duri开发者_StackOverflowng the execution of the line 3 of my second class (as shown below).

This is the code of my second class:

class Person(ip : String, port : Int) extends Actor{ 
        val node = Node(ip, port) 
        var server  = select(node, 'myName)    // <'----- program crashes here 
        def act(){ 
                while(true){ 
                        receive { 
                                case Post(msg) => //do something 
                                case Stop => exit() 
                        } 
                } 
        } 
}

Does anyboy know a solution for this error or any idea or have any experience on running remote actors on Android ?

thanks


I found the problem! I looked the source of remote actors, and the function "generatePort" in "TcpService" contains a recursive call to found a free socket port. Android didn't give port because... the AndroidManifest.xml must contains the INTERNET permission to use socket.

I hope this topic will help somebody


There has been some problems with Androids stack-limitations. For example the dispatch json library has been known (http://dispatch.databinder.net/Lift-JSON) to blow the stack because of its use of parser combinators.

Take a look at this post http://groups.google.com/group/android-developers/browse_thread/thread/d880c3d5777127d9 . The second post describes how you can create a thread with bigger stack through this constructor: http://developer.android.com/reference/java/lang/Thread.html#Thread%28java.lang.ThreadGroup,%20java.lang.Runnable,%20java.lang.String,%20long%29

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜