Open gituser1000000 opened 1 year ago
This issue was reported earlier in #1209, but I wasn't able to reproduce the issue, probably due to this thing you mentioned:
Users with devices having more memory might not have noticed the freezes too often since it could take a longer time to deplete the free memory.
I do have another device with 4GB of RAM. I'll try to reproduce this issue on that device with the steps you provided.
It looks like memory leaks after each time processing a letter, or a chunk of letters, as we're typing.
I did some research about this earlier, there is a chance that this issue occurs due to android-tree-sitter or the Java grammar (as everytime this was reported, the user was editing/working in a Java file, and you mentioned the same thing).
This issue was reported earlier in https://github.com/AndroidIDEOfficial/AndroidIDE/issues/1209 ...
I have also encountered #1209 a few times, but according to my observation, the symtoms seem different than those in this issue.
In this issue, the whole device freezes. The screen is not responsive (it might show some signs of a response once in a while but for the most part, nothing). The power button is also not responsive so the screen can't be turned on and off at will. This seems to indicate a typical critically-low or out-of-memory condition on a device.
In my attempts to find the memory leak, the AdroidIDE process's memory usage started out with just somewhere between less than 100MB to 200MB or so. After only a short time doing the steps I mentioned before, I could get the process's memory usage growing to a few Gigabytes, until it finally slowed down and froze.
It looks like memory leaks after each time processing a letter, or a chunk of letters, as we're typing.
I have made some improvements in this regard. The recent commits add an object pool implementation for tree sitter objects so that the objects are recycled and reused instead of new objects being recreated. This is expected to improve performance but I still have to do some more tests.
I've also noticed that even by closing the project and exiting the IDE, the memory is still not released and would show the same when reopening the IDE and project.
This was being caused by the Gradle Daemon and the Tooling API server (both run in a separate JVM process) NOT being stopped when the project was closed. The recent commits fix this issue and it works as expected in my tests. Now, the Gradle daemon and the tooling server are stopped as soon as you close the project (almost immediately), releasing held resources. However, if a build (project sync or task execution) is in progress, then the Gradle daemon might take some time to shut down properly. The tooling API server is stopped as soon as the daemon is stopped.
I really hope this memory leak would be fixed soon in the next release. Using the latest release, I have to keep going into developer options to check for the IDE's memory usage. If the memory usage is getting high, I would need to close the project and restart the IDE, hoping the memory is released and avoiding those dreadful random system freezes.
For now, I have to live with the fact that the more I type in the editor, the sooner the freezes come.
I have tried the latest 2.6.0-beta release but unfortunately didn't see any improvement regarding the memory leak issue.
Using the same method typing and undoing repeatedly in a basic project for about 5 to 10 minutes, I saw memory usage climb steadily from around 100MB to 2 to 3 GB. The device froze for a several minutes then the IDE silently restarted.
Unfortunately, I haven't got time to work on this issue specifically. I plan to work on this for v2.7.0-beta, but I forgot to add this issue to the milestone, sorry for that.
A little bit of how this leak occurs during my use: I'm programming normally, compiling the project several times, each time I compile it seems that the IDE becomes slightly slower, but it's not something that aggravating, but I noticed that after one of theses compilations, IDE starts to get much slower than other times, (remembering that I always open the APK after compilation) and after returning to the IDE I notice the difference
What I know so far is that due to a problem in the logsender, the logs accumulate and I have already had 4 complete IDE crashes because of this, but I know this also happened before, but i think this is also a source of one of memory leak this issue https://github.com/AndroidIDEOfficial/AndroidIDE/issues/1154
I think the logsender issue is unrelated to this. I have app logging disabled in settings and the leak still happens as before.
In a test basic application, for every letter typed, IDE logs spit out:
... Created 16 resource tables for 16 dependencies of module ':app' ...
We probably type hundreds of letters every few minutes. So maybe this is where the memory leak gets accumulated?
I think the logsender issue is unrelated to this. I have app logging disabled in settings and the leak still happens as before.
In a test basic application, for every letter typed, IDE logs spit out:
... Created 16 resource tables for 16 dependencies of module ':app' ...
We probably type hundreds of letters every few minutes. So maybe this is where the memory leak gets accumulated?
In fact, I know that logsender is the smallest of the leaks, I just mentioned it because that's what I really saw happening, but the leaks that always occur are in another part of the IDE, as was detailed once by Itsaky He already knows where some leaks are. I don't know if all of them, but I think he already has a direction
I'm glad he's making progress regarding this issue. People with super phones with 999GBs of RAM who don't do long coding sessions (or reset the IDE frequently) might not be aware of the issue. It only takes me around 2000 keystrokes of typing (on a 4GB device) before I need to reset the IDE to avoid the freeze.
I think the logsender issue is unrelated to this. I have app logging disabled in settings and the leak still happens as before.
In a test basic application, for every letter typed, IDE logs spit out:
... Created 16 resource tables for 16 dependencies of module ':app' ...
We probably type hundreds of letters every few minutes. So maybe this is where the memory leak gets accumulated?
The resource tables are created when you synchronise the project or after you edit and save an XML file. If this is happening on every key stroke, then there is definitely something wrong with this. Could you share the IDE logs for this?
In my opinion, the JAR file cache consumes a significant amount of memory. I've been planning to work on this in #1395. I'm not sure if we can use the same caching mechanism for XML resource tables. But if we could, it would result in a huge memory usage improvement.
Apart from these, there are a lot of other things that could improve/reduce the memory usage (or at least reduce object allocation/deallocation). For example, migrating from Java functional classes (Consumer
, BiConsumer
, Function
, Runnable
etc) to inlined functions in Kotlin would be a great improvement, but we need to migrate the Java classes to Kotlin as well.
I simply typed 10 letter 'a'.
AndroidModule I Created 16 resource tables for 16 dependencies of module ':app'
JavaCompletionProvider I Complete at MainActivity.java(41,9)...
CachedCompletion I ...unequal change in prefix and column
JavaCompletionProvider I ...cannot use cached completions
StopWatch D [TreeSitter] Parsing completed in 1ms
StopWatch D [MainActivity.java] Prune method bodies completed in 4ms
StopWatch D Parsed treees in 6ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 17ms
JavaCompletionProvider I ...compiled in 39ms
..ScopeCompletionProvider I ...found 12 scope members
..mportCompletionProvider I ...found 0 static imports
..NamesCompletionProvider I ...found 400 class names
JavaCompletionProvider I Found 50 items (incomplete) in 78 ms
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 1ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
StopWatch D Parsed treees in 26ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 156ms
NavDeepLinkBuilder I Analyze file completed. Found 4 diagnostic items
AndroidModule I Created 16 resource tables for 16 dependencies of module ':app'
JavaCompletionProvider I Complete at MainActivity.java(41,10)...
JavaCompletionProvider I ...cached completions are empty
StopWatch D [TreeSitter] Parsing completed in 0ms
StopWatch D [MainActivity.java] Prune method bodies completed in 8ms
StopWatch D Parsed treees in 10ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 6ms
JavaCompletionProvider I ...compiled in 29ms
..ScopeCompletionProvider I ...found 0 scope members
..mportCompletionProvider I ...found 0 static imports
..NamesCompletionProvider I ...found 0 class names
JavaCompletionProvider I Found 0 items in 49 ms
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 1ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
StopWatch D Parsed treees in 20ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 142ms
NavDeepLinkBuilder I Analyze file completed. Found 4 diagnostic items
AndroidModule I Created 16 resource tables for 16 dependencies of module ':app'
JavaCompletionProvider I Complete at MainActivity.java(41,11)...
JavaCompletionProvider I ...cached completions are empty
StopWatch D [TreeSitter] Parsing completed in 0ms
StopWatch D [MainActivity.java] Prune method bodies completed in 5ms
StopWatch D Parsed treees in 7ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 6ms
JavaCompletionProvider I ...compiled in 26ms
..ScopeCompletionProvider I ...found 0 scope members
..mportCompletionProvider I ...found 0 static imports
..NamesCompletionProvider I ...found 0 class names
JavaCompletionProvider I Found 0 items in 44 ms
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 2ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
StopWatch D Parsed treees in 18ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 131ms
NavDeepLinkBuilder I Analyze file completed. Found 4 diagnostic items
EditorActivity D [onPause] Opened files cache reset to OpenedFilesCache(selectedFile=/storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java, allFiles=[OpenedFile(filePath=/storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java, selection=Range(start=Position(line=41, column=11, index=1282), end=Position(line=41, column=11, index=1282)))])
BootClassProvider D Indexing boot classpath: /data/data/com.itsaky.androidide/files/home/.androidide/android.jar
AndroidModule I Created 16 resource tables for 16 dependencies of module ':app'
JavaCompletionProvider I Complete at MainActivity.java(41,12)...
JavaCompletionProvider I ...cached completions are empty
StopWatch D [TreeSitter] Parsing completed in 1ms
StopWatch D [MainActivity.java] Prune method bodies completed in 5ms
StopWatch D Parsed treees in 7ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 8ms
JavaCompletionProvider I ...compiled in 29ms
..ScopeCompletionProvider I ...found 0 scope members
..mportCompletionProvider I ...found 0 static imports
..NamesCompletionProvider I ...found 0 class names
JavaCompletionProvider I Found 0 items in 47 ms
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 1ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
StopWatch D Parsed treees in 26ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 135ms
NavDeepLinkBuilder I Analyze file completed. Found 4 diagnostic items
AndroidModule I Created 16 resource tables for 16 dependencies of module ':app'
JavaCompletionProvider I Complete at MainActivity.java(41,13)...
JavaCompletionProvider I ...cached completions are empty
StopWatch D [TreeSitter] Parsing completed in 1ms
StopWatch D [MainActivity.java] Prune method bodies completed in 4ms
StopWatch D Parsed treees in 6ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 5ms
JavaCompletionProvider I ...compiled in 36ms
..ScopeCompletionProvider I ...found 0 scope members
..mportCompletionProvider I ...found 0 static imports
..NamesCompletionProvider I ...found 0 class names
JavaCompletionProvider I Found 0 items in 60 ms
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 0ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
StopWatch D Parsed treees in 21ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 131ms
NavDeepLinkBuilder I Analyze file completed. Found 4 diagnostic items
AndroidModule I Created 16 resource tables for 16 dependencies of module ':app'
JavaCompletionProvider I Complete at MainActivity.java(41,14)...
JavaCompletionProvider I ...cached completions are empty
StopWatch D [TreeSitter] Parsing completed in 1ms
StopWatch D [MainActivity.java] Prune method bodies completed in 6ms
StopWatch D Parsed treees in 10ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 21ms
JavaCompletionProvider I ...compiled in 46ms
..ScopeCompletionProvider I ...found 0 scope members
..mportCompletionProvider I ...found 0 static imports
..NamesCompletionProvider I ...found 0 class names
JavaCompletionProvider I Found 0 items in 74 ms
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 1ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
StopWatch D Parsed treees in 18ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 134ms
NavDeepLinkBuilder I Analyze file completed. Found 4 diagnostic items
AndroidModule I Created 16 resource tables for 16 dependencies of module ':app'
JavaCompletionProvider I Complete at MainActivity.java(41,15)...
JavaCompletionProvider I ...cached completions are empty
StopWatch D [TreeSitter] Parsing completed in 1ms
StopWatch D [MainActivity.java] Prune method bodies completed in 3ms
StopWatch D Parsed treees in 5ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 5ms
JavaCompletionProvider I ...compiled in 18ms
..ScopeCompletionProvider I ...found 0 scope members
..mportCompletionProvider I ...found 0 static imports
..NamesCompletionProvider I ...found 0 class names
JavaCompletionProvider I Found 0 items in 37 ms
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 2ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
StopWatch D Parsed treees in 21ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 136ms
NavDeepLinkBuilder I Analyze file completed. Found 4 diagnostic items
AndroidModule I Created 16 resource tables for 16 dependencies of module ':app'
JavaCompletionProvider I Complete at MainActivity.java(41,16)...
JavaCompletionProvider I ...cached completions are empty
StopWatch D [TreeSitter] Parsing completed in 1ms
StopWatch D [MainActivity.java] Prune method bodies completed in 4ms
StopWatch D Parsed treees in 6ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 6ms
JavaCompletionProvider I ...compiled in 25ms
..ScopeCompletionProvider I ...found 0 scope members
..mportCompletionProvider I ...found 0 static imports
..NamesCompletionProvider I ...found 0 class names
JavaCompletionProvider I Found 0 items in 49 ms
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 1ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
StopWatch D Parsed treees in 20ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 173ms
NavDeepLinkBuilder I Analyze file completed. Found 4 diagnostic items
AndroidModule I Created 16 resource tables for 16 dependencies of module ':app'
JavaCompletionProvider I Complete at MainActivity.java(41,17)...
JavaCompletionProvider I ...cached completions are empty
StopWatch D [TreeSitter] Parsing completed in 0ms
StopWatch D [MainActivity.java] Prune method bodies completed in 7ms
StopWatch D Parsed treees in 9ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 9ms
JavaCompletionProvider I ...compiled in 39ms
..ScopeCompletionProvider I ...found 0 scope members
..mportCompletionProvider I ...found 0 static imports
..NamesCompletionProvider I ...found 0 class names
JavaCompletionProvider I Found 0 items in 58 ms
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 1ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
StopWatch D Parsed treees in 19ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 126ms
NavDeepLinkBuilder I Analyze file completed. Found 4 diagnostic items
AndroidModule I Created 16 resource tables for 16 dependencies of module ':app'
JavaCompletionProvider I Complete at MainActivity.java(41,18)...
JavaCompletionProvider I ...cached completions are empty
StopWatch D [TreeSitter] Parsing completed in 0ms
StopWatch D [MainActivity.java] Prune method bodies completed in 5ms
StopWatch D Parsed treees in 17ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 14ms
JavaCompletionProvider I ...compiled in 46ms
..ScopeCompletionProvider I ...found 0 scope members
..mportCompletionProvider I ...found 0 static imports
..NamesCompletionProvider I ...found 0 class names
JavaCompletionProvider I Found 0 items in 76 ms
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 1ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
StopWatch D Parsed treees in 25ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 137ms
NavDeepLinkBuilder I Analyze file completed. Found 4 diagnostic items
Thanks for the logs. I'm able to reproduce the issue. I think the issue can be resolved if we skip indexing the already indexed dependency resources. The contents of the resource directory for a dependency downloaded by Gradle doesn't change, unless the user manually edits those resources.
Don't know why I didn't implement this when creating the API.
I think the issue can be resolved if we skip indexing the already indexed dependency resources.
Great! This bug has been bugging me for the longest time. Do you think we could move this fix to 2.6.1-beta instead of 2.7.0-beta? In my opinion, a memory leak that could freeze the whole system in a short time is important enough to be fixed as soon as possible.
I think the issue can be resolved if we skip indexing the already indexed dependency resources.
Great! This bug has been bugging me for the longest time. Do you think we could move this fix to 2.6.1-beta instead of 2.7.0-beta? In my opinion, a memory leak that could freeze the whole system in a short time is important enough to be fixed as soon as possible.
I can fix this specific bug in v2.6.1-beta. However, this whole memory usage issue is gonna take some time to be resolved.
Thanks for the logs. I'm able to reproduce the issue. I think the issue can be resolved if we skip indexing the already indexed dependency resources. The contents of the resource directory for a dependency downloaded by Gradle doesn't change, unless the user manually edits those resources.
Don't know why I didn't implement this when creating the API.
I was wrong about this, and the log lines are misleading. The IDE creates the resource tables only once. Even if you re-sync the project, already indexed dependency resources are not indexed again. However, when you edit an XML file, the resource table for that file's module is updated (only the module's resource table, not it's dependencies).
I was so excited about leaving this bug behind us soon, but nooo! I guess we would have to continue looking for something that keeps sucking up memory on our every key stroke.
There has been some progress on this issue. Some changes were introduced in the IDE as well as ATS (Android Tree Sitter) :
TSTree
instances were not closed after use, causing memory leaks. As these objects are allocated in JNI using malloc
, the allocated memory is not de-allocated unless we do it manually.TSParser
, theUTF16String
(from ATS) is converted to a C-style string and then passed to the tree sitter's parser. However, this C-style string was not released after use. This has been fixed.TSQuery
instance, the query source represented with Java's String
is converted to a C-style string and then passed to the tree sitter's query parser. This C-style string was also not released, causing a memory leak. This has been fixed.These patches are available in v2.6.1-beta.
Nice! It's leaking much more slowly. However, there are maybe(?) still some other leaks somewhere.
I have been testing on a basic project for a couple of hours (not continuously but on and off). I only type randomly then undo. The memory usage for the IDE has gone up to about 500MB so far but it's still growing. It did sometimes went down a little however.
I've had to switch back and forth between the IDE and the system's running processes to monitor the memory usage (not too convenient to do). I wish the pending feature to see the memory usage from within the IDE were already implemented in this beta so users could be more aware of any unusual memory usage expanding.
I also noticed some red lines in the logs while doing the random typing test. Here are some sample logs.
SynchronizedTask E An error occurred while working with compilation task
SynchronizedTask E java.lang.StringIndexOutOfBoundsException: length=1862; index=1869
SynchronizedTask E at java.lang.String.substring(String.java:2060)
SynchronizedTask E at java.lang.String.subSequence(String.java:2107)
SynchronizedTask E at androidx.navigation.NavDeepLinkBuilder.access$doAnalyze(Unknown Source:510)
SynchronizedTask E at com.itsaky.androidide.lsp.java.providers.JavaDiagnosticProvider$AnalyzingThread.run(Unknown Source:28)
SynchronizedTask E
SynchronizedTask E
NavDeepLinkBuilder W Unable to analyze file
NavDeepLinkBuilder W java.lang.StringIndexOutOfBoundsException: length=1862; index=1869
NavDeepLinkBuilder W at java.lang.String.substring(String.java:2060)
NavDeepLinkBuilder W at java.lang.String.subSequence(String.java:2107)
NavDeepLinkBuilder W at androidx.navigation.NavDeepLinkBuilder.access$doAnalyze(Unknown Source:510)
NavDeepLinkBuilder W at com.itsaky.androidide.lsp.java.providers.JavaDiagnosticProvider$AnalyzingThread.run(Unknown Source:28)
NavDeepLinkBuilder W
NavDeepLinkBuilder W
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 1ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
StopWatch D Parsed treees in 22ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 138ms
NavDeepLinkBuilder I Analyze file completed. Found 24 diagnostic items
AbstractLanguageClient W Limiting diagnostics to 20 items for file MainActivity.java
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 0ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
NavDeepLinkBuilder D Using cached analyze results...
AbstractLanguageClient W Limiting diagnostics to 20 items for file MainActivity.java
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 1ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
StopWatch D Parsed treees in 13ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 106ms
NavDeepLinkBuilder I Analyze file completed. Found 15 diagnostic items
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 1ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
NavDeepLinkBuilder D Using cached analyze results...
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 2ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
StopWatch D Parsed treees in 17ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 125ms
SynchronizedTask E An error occurred while working with compilation task
SynchronizedTask E java.lang.StringIndexOutOfBoundsException: length=1480; index=1543
SynchronizedTask E at java.lang.String.substring(String.java:2060)
SynchronizedTask E at java.lang.String.subSequence(String.java:2107)
SynchronizedTask E at androidx.navigation.NavDeepLinkBuilder.access$doAnalyze(Unknown Source:510)
SynchronizedTask E at com.itsaky.androidide.lsp.java.providers.JavaDiagnosticProvider$AnalyzingThread.run(Unknown Source:28)
SynchronizedTask E
SynchronizedTask E
NavDeepLinkBuilder W Unable to analyze file
NavDeepLinkBuilder W java.lang.StringIndexOutOfBoundsException: length=1480; index=1543
NavDeepLinkBuilder W at java.lang.String.substring(String.java:2060)
NavDeepLinkBuilder W at java.lang.String.subSequence(String.java:2107)
NavDeepLinkBuilder W at androidx.navigation.NavDeepLinkBuilder.access$doAnalyze(Unknown Source:510)
NavDeepLinkBuilder W at com.itsaky.androidide.lsp.java.providers.JavaDiagnosticProvider$AnalyzingThread.run(Unknown Source:28)
NavDeepLinkBuilder W
NavDeepLinkBuilder W
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 1ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
NavDeepLinkBuilder D Using cached analyze results...
BootClassProvider I Skipping indexing for boot classpath as it is already indexed: /data/data/com.itsaky.androidide/files/home/android-sdk/platforms/android-32/android.jar
StopWatch D Indexing 1 bootclasspaths completed in 1ms
NavDeepLinkBuilder D Analyzing: /storage/emulated/0/AndroidIDEProjects/MyApplicationBasic/app/src/main/java/com/example/myapplicationbasic/MainActivity.java
StopWatch D Parsed treees in 13ms
StopWatch D Processed trees in 0ms
StopWatch D Analyzed all trees in 109ms
SynchronizedTask E An error occurred while working with compilation task
SynchronizedTask E java.lang.StringIndexOutOfBoundsException: length=1386; index=1444
SynchronizedTask E at java.lang.String.substring(String.java:2060)
SynchronizedTask E at java.lang.String.subSequence(String.java:2107)
SynchronizedTask E at androidx.navigation.NavDeepLinkBuilder.access$doAnalyze(Unknown Source:510)
SynchronizedTask E at com.itsaky.androidide.lsp.java.providers.JavaDiagnosticProvider$AnalyzingThread.run(Unknown Source:28)
SynchronizedTask E
SynchronizedTask E
NavDeepLinkBuilder W Unable to analyze file
NavDeepLinkBuilder W java.lang.StringIndexOutOfBoundsException: length=1386; index=1444
NavDeepLinkBuilder W at java.lang.String.substring(String.java:2060)
NavDeepLinkBuilder W at java.lang.String.subSequence(String.java:2107)
NavDeepLinkBuilder W at androidx.navigation.NavDeepLinkBuilder.access$doAnalyze(Unknown Source:510)
NavDeepLinkBuilder W at com.itsaky.androidide.lsp.java.providers.JavaDiagnosticProvider$AnalyzingThread.run(Unknown Source:28)
NavDeepLinkBuilder W
NavDeepLinkBuilder W
and another,
SynchronizedTask E An error occurred while working with compilation task
SynchronizedTask E io.github.rosemoe.sora.lang.completion.CompletionCancelledException
SynchronizedTask E at io.github.rosemoe.sora.lang.completion.CompletionPublisher.checkCancelled(Unknown Source:20)
SynchronizedTask E at com.itsaky.androidide.tasks.JobCancelChecker.abortIfCancelled(Unknown Source:13)
SynchronizedTask E at com.itsaky.androidide.templates.ParameterBuilder.abortCompletionIfCancelled(Unknown Source:14)
SynchronizedTask E at com.itsaky.androidide.lsp.java.providers.completion.IJavaCompletionProvider.matchLevel(Unknown Source:15)
SynchronizedTask E at com.itsaky.androidide.lsp.java.providers.completion.ClassNamesCompletionProvider.doComplete(Unknown Source:220)
SynchronizedTask E at com.itsaky.androidide.lsp.java.providers.completion.IJavaCompletionProvider.complete(Unknown Source:102)
SynchronizedTask E at com.itsaky.androidide.lsp.java.providers.completion.IdentifierCompletionProvider.doComplete(Unknown Source:216)
SynchronizedTask E at com.itsaky.androidide.lsp.java.providers.completion.IJavaCompletionProvider.complete(Unknown Source:102)
SynchronizedTask E at com.itsaky.androidide.lsp.java.providers.CompletionProvider$$ExternalSyntheticLambda0.invoke(Unknown Source:443)
SynchronizedTask E at com.itsaky.androidide.lsp.java.compiler.SynchronizedTask.get(Unknown Source:10)
SynchronizedTask E at com.itsaky.androidide.lsp.java.providers.CompletionProvider.completeInternal(Unknown Source:794)
SynchronizedTask E at com.itsaky.androidide.lsp.java.providers.CompletionProvider.complete(Unknown Source:91)
SynchronizedTask E at com.itsaky.androidide.lsp.java.JavaLanguageServer.complete(Unknown Source:125)
SynchronizedTask E at com.itsaky.androidide.editor.language.IDELanguage.doComplete(Unknown Source:120)
SynchronizedTask E at com.itsaky.androidide.editor.language.IDELanguage.requireAutoComplete(Unknown Source:39)
SynchronizedTask E at io.github.rosemoe.sora.widget.component.EditorAutoCompletion$CompletionThread.run(Unknown Source:10)
SynchronizedTask E
SynchronizedTask E
JavaCompletionProvider E An error occurred while computing completions
JavaCompletionProvider E io.github.rosemoe.sora.lang.completion.CompletionCancelledException
JavaCompletionProvider E at io.github.rosemoe.sora.lang.completion.CompletionPublisher.checkCancelled(Unknown Source:20)
JavaCompletionProvider E at com.itsaky.androidide.tasks.JobCancelChecker.abortIfCancelled(Unknown Source:13)
JavaCompletionProvider E at com.itsaky.androidide.templates.ParameterBuilder.abortCompletionIfCancelled(Unknown Source:14)
JavaCompletionProvider E at com.itsaky.androidide.lsp.java.providers.completion.IJavaCompletionProvider.matchLevel(Unknown Source:15)
JavaCompletionProvider E at com.itsaky.androidide.lsp.java.providers.completion.ClassNamesCompletionProvider.doComplete(Unknown Source:220)
JavaCompletionProvider E at com.itsaky.androidide.lsp.java.providers.completion.IJavaCompletionProvider.complete(Unknown Source:102)
JavaCompletionProvider E at com.itsaky.androidide.lsp.java.providers.completion.IdentifierCompletionProvider.doComplete(Unknown Source:216)
JavaCompletionProvider E at com.itsaky.androidide.lsp.java.providers.completion.IJavaCompletionProvider.complete(Unknown Source:102)
JavaCompletionProvider E at com.itsaky.androidide.lsp.java.providers.CompletionProvider$$ExternalSyntheticLambda0.invoke(Unknown Source:443)
JavaCompletionProvider E at com.itsaky.androidide.lsp.java.compiler.SynchronizedTask.get(Unknown Source:10)
JavaCompletionProvider E at com.itsaky.androidide.lsp.java.providers.CompletionProvider.completeInternal(Unknown Source:794)
JavaCompletionProvider E at com.itsaky.androidide.lsp.java.providers.CompletionProvider.complete(Unknown Source:91)
JavaCompletionProvider E at com.itsaky.androidide.lsp.java.JavaLanguageServer.complete(Unknown Source:125)
JavaCompletionProvider E at com.itsaky.androidide.editor.language.IDELanguage.doComplete(Unknown Source:120)
JavaCompletionProvider E at com.itsaky.androidide.editor.language.IDELanguage.requireAutoComplete(Unknown Source:39)
JavaCompletionProvider E at io.github.rosemoe.sora.widget.component.EditorAutoCompletion$CompletionThread.run(Unknown Source:10)
JavaCompletionProvider E
JavaCompletionProvider E
What happened?
I've had system freezes at random (seemingly at first) times while using AndroidIDE. Sometimes it happens more than once in a day, while other times, days.
When it happens, everything slows down to a crawl, then freezes. The device is not responsive, top edge swipe, bottom edge swipe, nothing, not even the power button. The device also gets really warm. If I just left it alone (which I don't usually do) for a long while it sometimes recovers. When running the IDE again, it went through the initialization, and sometimes the in-progress indicator even got stuck and never stopped. Most of the time, I just got too impatient and kept tapping everywhere. Too many times pressing the power button turned it into a hold and the device just reset itself.
I think I might have found the steps to show where it's leaking.
It looks like memory leaks after each time processing a letter, or a chunk of letters, as we're typing.
What I did to observe the leak was:
In my test, it could increase sometimes more than a 100MB of memory each time typing a few dozen letters. When the free memory becomes low, everything gets slower and slower until it finally freezes. I've also noticed that even by closing the project and exiting the IDE, the memory is still not released and would show the same when reopening the IDE and project.
Users with devices having more memory might not have noticed the freezes too often since it could take a longer time to deplete the free memory. For users with 4 or less Gigabytes of memory, they are more likely to encounter the lag and freezes.
When this bug is fixed, I think users (especially with limited RAM) might see a nice boost in usability.
What's the expected behavior?
Memory should not leak causing lag and freezes.
What version of AndroidIDE you're using?
v2.5.2 (debug builds)
Relevant log output
No response
Duplicate issues
Code of Conduct