Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize route collecting: Reduce memory usage when there's no routes.cache #488

Open
ngocdaothanh opened this issue Dec 12, 2014 · 1 comment
Assignees
Labels

Comments

@ngocdaothanh
Copy link
Member

1 - Problem

When running from console:

java.lang.OutOfMemoryError: PermGen space
Dumping heap to java_pid32500.hprof ...
Heap dump file created [107664867 bytes in 0.659 secs]

When running inside Eclipse, Eclipse will freeze the process.

When there's no routes.cache, Xitrum currently has to load all classes in classpath in order to collect routes from annotations.

When running from console:

2 - Solution

@ngocdaothanh ngocdaothanh self-assigned this Dec 12, 2014
@ngocdaothanh ngocdaothanh modified the milestones: Xitrum 3.21, Xitrum 3.22 Dec 12, 2014
@ngocdaothanh ngocdaothanh changed the title Reduce memory usage when collecting routes and there's no routes.cache Optimize route collecting: Reduce memory usage when there's no routes.cache Jan 12, 2015
@ngocdaothanh ngocdaothanh modified the milestones: Xitrum 3.23, Xitrum 3.22 Jan 13, 2015
@ngocdaothanh ngocdaothanh modified the milestones: Xitrum 3.24, Xitrum 3.23 Mar 13, 2015
@ngocdaothanh ngocdaothanh modified the milestones: Xitrum 3.24.1, Xitrum 3.24.0 May 22, 2015
@ngocdaothanh
Copy link
Member Author

See https://github.com/scala/scala/tree/2.11.x/src/scalap/scala/tools/scalap

xitrum-new is used for the below examples.


From command line:

scalap SiteIndex
=>

package quickstart.action
@xitrum.annotation.GET("")
class SiteIndex extends scala.AnyRef with quickstart.action.DefaultLayout {
  def this() = { /* compiled code */ }
  def execute(): scala.Unit = { /* compiled code */ }
}

From SBT console:

import scala.tools.scalap.scalax.rules.scalasig._

val b = ByteCode.forClass(classOf[quickstart.action.SiteIndex])  // ByteCode
val c = ClassFileParser.parse(b)  // ClassFile
val s = ScalaSigParser.parse(c).get  // ScalaSig

scala.tools.scalap.Main.parseScalaSignature(s, false)
=>
package quickstart.action
@xitrum.annotation.GET("")
class SiteIndex extends scala.AnyRef with quickstart.action.DefaultLayout {
  def this() = { /* compiled code */ }
  def execute(): scala.Unit = { /* compiled code */ }
}

The above is printed from ScalaSigPrinter's printClass:
https://github.com/scala/scala/blob/2.11.x/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala

To get a ClassSymbol:

val cs = s.topLevelClasses(0)

@ngocdaothanh ngocdaothanh modified the milestones: Xitrum 3.24.2, Xitrum 3.24.1 Jul 29, 2015
@ngocdaothanh ngocdaothanh removed this from the Xitrum 3.28.0 milestone Aug 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant