#20150127-01 :: eclipse :: GC overhead limit exceeded

eclipse에 새로운 안드로이드 프로젝트를 임포트 하고 실행을 했더니

"GC overhead limit exceeded" 에러가 발생하면서 엉망진창이 되었습니다.


이유는 이클립스에서 JVM 구동에 필요한 메모리에 제한이 걸려있기 때문입니다.

아래와 같이 메모리를 늘려줍니다.


$ vi /work/apps/eclipse/eclipse/eclipse.ini

...

-XX:MaxPermSize=1024m
-Xms512m
-Xmx1024m




#20150126-01 :: eclipse :: eclipse를 ubuntu launcher에 등록하기

우분투 12.04에 이클립스를 설치 한 후 런처에 바로가기를 등록하려고 합니다.

먼저 아래와 같은 내용을 작성합니다.


$ vi /work/apps/eclipse/eclipse.descktop

[Desktop Entry]
Type=Application
Name=Eclipse
Comment=Eclipse Integrated Development Environment
Icon=/work/apps/eclipse/eclipse/icon.xpm
Exec=/work/apps/eclipse/eclipse/eclipse
Terminal=false
Categories=Development;IDE;Java;
StartupWMClass=Eclipse


아래의 위치에 작성한 파일을 심볼릭 링크로 연결합니다.

$ cd ~/.local/share/applications

$ ln -s /work/apps/eclipse/eclipse.desktop eclipse.desktop


아래의 명령을 치면 폴더가 열립니다.

$  nautilus ~/.local/share/applications


폴더에 있는 eclipse.desktop 파일을 런청에 드래그&드랍 하면

런처에 바로가기 등록 됩니다.



#20150119-03 :: go :: go를 이용한 TCP/IP Echo Server Example

아래는 go를 이용한 간단한 TCP/IP Echo Server 예제 입니다.

관리 용이성을 위해 서버와 클라이언트를 한 코드에 넣었습니다.


package main


import (

  "bufio"

  "fmt"

  "net"

  "os"

  "time"

)


func main() {


  send := make(chan string)

  quit := make(chan string)


  addr, err := net.ResolveTCPAddr("tcp", ":9000")


  ln, err := net.ListenTCP("tcp", addr)

  if err != nil {

    fmt.Println(err.Error())

    return;

  }


  go runServer(ln, quit)


  time.Sleep(time.Duration(1) * time.Second)


  conn, err := net.Dial("tcp", "127.0.0.1:9000")

  if err != nil {

    fmt.Println(err.Error())

    return;

  }


  go runClient(conn, quit)

  go runScan(send, quit)


  stop := false

  for !stop {


    fmt.Println("main loop ...")


    select {

    case text, ok := <- send:

      if !ok {

        ln.Close()

        conn.Close()

        stop = true

      }

      conn.Write([]byte(text))

    case err := <- quit:

      fmt.Println(err)

      stop = true

    }

  }


  fmt.Println("complete.")

}


func runScan(send chan string, quit chan string) {


  fmt.Println("runScan begin.")


  scanner := bufio.NewScanner(os.Stdin)

  for scanner.Scan() {

    text := scanner.Text()

    if text == "." {

      close(send)

      break

    }


    send <- text

  }

  

  fmt.Println("runScan end.")

}


func runServer(ln *net.TCPListener, quit chan string) {


  fmt.Println("runServer begin.")


  for {

    conn, err := ln.Accept()

    if err != nil {

      quit <- err.Error()

      break

    }


    go runSession(conn, quit)

  }


  fmt.Println("runServer end.")

}


func runSession(conn net.Conn, quit chan string) {


  fmt.Println("runSession begin.")


  buf := make([]byte, 1024)


  for {

    size, err := conn.Read(buf)

    if err != nil || size == 0 {

      quit <- err.Error()

      break

    }


    _, err = conn.Write(buf[:size])

    if err != nil {

      quit <- err.Error()

      break

    }

  }


  fmt.Println("runSession end.")

}


func runClient(conn net.Conn, quit chan string) {


  fmt.Println("runClient begin.")


  buf := make([]byte, 1024)


  for {

    size, err := conn.Read(buf)

    if err != nil {

      quit <- err.Error()

      break

    }


    fmt.Println(string(buf[:size]))

  }


  fmt.Println("runClient end.")

}