| Summary: | [Xtend][Memory Leak] Create Extensions - Possibility to clear caches. | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Christian Dietrich <christian.dietrich.opensource> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | mail, sebastian.zarnekow, sven.efftinge |
| Version: | unspecified | Flags: | sven.efftinge:
indigo+
|
| Target Milestone: | SR2 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
Christian Dietrich
If you use the create extensions in a long running environment (i.e. in the IDE) you should obtain and discard a fresh instance using a Provider in order to control the lifecycle of the state. However the ongoing refactoring will make the field visible and accessible. Good to hear, what will be the solution for the builderparticipant/igenerator: will i have to many call the clears there too? ~Christian You should obtain a fresh instance for each transformation. since builderparticipant and its use of igenerator are infrastructure provided by xtext it is hard to do it yourself besides cleaning up manually at the end of the dogenerate method. Maybe I wasn't clear (or I misunderstood you ;-)):
I meant something like this:
class MyGenerator implements IGenerator {
@Inject Provider<MyTransformationCode> transformerProvider
def generate(Resoure res, IFileSystemAccess fsa) {
transformerProvider.get().doTransformation(res, fsa)
}
}
The lifecycle of the cache state is directly associated to the lifecycle of instances of the Xtend class containing create functions. That is how it is meant to be used.
Hi, yes this will work but i still don't know how to then solve the singleton problem: you have Xtend class A that has a createExtension createA and you have XtendClasses B and C that use A.createA how to make shure that B and C get the same instance without declaring A as Singleton. and if a is a singleton using a provider won't help You could a) pass the instance around b) marking it a singleton and explicitly clear the cache, when you think it's a good idea to do so. Thats ok for me so far - never the less it still feels like a workarround The cache variable is now visible from within the Xtend class which allows to create a function that clears the cache explicitly. Closing all bugs that were set to RESOLVED before Neon.0 Closing all bugs that were set to RESOLVED before Neon.0 |