flutter-intellij icon indicating copy to clipboard operation
flutter-intellij copied to clipboard

Problems when printing a 10e6 character String to console

Open MAlazhariy opened this issue 3 years ago • 7 comments

What happened

(please describe what you were doing when this exception occurred)

I wrote this command below :) const int printableCharsStartIndex = 32; const int charLength = 1114111 - printableCharsStartIndex; final List charCodes = List.generate(charLength, (index) => index+printableCharsStartIndex); final String chars = String.fromCharCodes(charCodes); print(chars.split('')); FlutterClipboard.copy(chars.split('').toString()).then((value) { print('DONE !'); });

Version information

Android Studio Bumblebee | 2021.1.1 Patch 1 • Flutter plugin io.flutter 64.1.2 • Dart plugin 211.7798

Error getting Flutter sdk information.

Exception

null

java.lang.reflect.InvocationTargetException
	at jdk.internal.reflect.GeneratedMethodAccessor62.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.intellij.execution.process.ProcessHandler$2.invoke(ProcessHandler.java:246)
	at com.sun.proxy.$Proxy34.onTextAvailable(Unknown Source)
	at com.intellij.execution.process.ProcessHandler.notifyTextAvailable(ProcessHandler.java:220)
	at com.intellij.execution.process.ColoredProcessHandler.coloredTextAvailable(ColoredProcessHandler.java:63)
	at io.flutter.utils.MostlySilentColoredProcessHandler.coloredTextAvailable(MostlySilentColoredProcessHandler.java:77)
	at com.intellij.execution.process.AnsiEscapeDecoder.processTextChunk(AnsiEscapeDecoder.java:100)
	at com.intellij.execution.process.AnsiEscapeDecoder.escapeText(AnsiEscapeDecoder.java:64)
	at com.intellij.execution.process.ColoredProcessHandler.notifyTextAvailable(ColoredProcessHandler.java:52)
	at com.intellij.execution.process.BaseOSProcessHandler$SimpleOutputReader.onTextAvailable(BaseOSProcessHandler.java:156)
	at com.intellij.util.io.BaseOutputReader.sendText(BaseOutputReader.java:206)
	at com.intellij.util.io.BaseOutputReader.processInput(BaseOutputReader.java:190)
	at com.intellij.util.io.BaseOutputReader.readAvailableBlocking(BaseOutputReader.java:137)
	at com.intellij.util.io.BaseDataReader.readAvailable(BaseDataReader.java:68)
	at com.intellij.util.io.BaseDataReader.doRun(BaseDataReader.java:158)
	at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:213)
	at com.intellij.util.io.BaseDataReader.lambda$start$0(BaseDataReader.java:51)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.OutOfMemoryError: Java heap space

MAlazhariy avatar Mar 08 '22 22:03 MAlazhariy

Please share a minimal and complete code sample along with the output of flutter doctor -v along with the complete error logs.

Were you running the Flutter code on an emulator or simulator? If so, what happens when you run on a physical device? What happens if you delete the print statement?

stevemessick avatar Mar 14 '22 22:03 stevemessick

Without additional information we're unfortunately not sure how to resolve this issue. We're going to close this bug for now, but please don't hesitate to comment on the bug if you have any more information for us; we're happy to reopen. Thanks for your contribution!

no-response[bot] avatar Mar 21 '22 22:03 no-response[bot]

My apologies, Steve, for the delay in responding.

The output of flutter doctor -v `[√] Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.19044.1586], locale en-US) • Flutter version 2.10.3 at C:\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 7e9793dee1 (3 weeks ago), 2022-03-02 11:23:12 -0600 • Engine revision bd539267b4 • Dart version 2.16.1 • DevTools version 2.9.2

[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) • Android SDK at C:\Users\MAlazhariy\AppData\Local\Android\sdk X cmdline-tools component is missing Run path/to/sdkmanager --install "cmdline-tools;latest" See https://developer.android.com/studio/command-line for more details. X Android license status unknown. Run flutter doctor --android-licenses to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.

[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop for Windows X Visual Studio not installed; this is necessary for Windows development. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2021.1) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)

[√] VS Code (version 1.65.2) • VS Code at C:\Users\MAlazhariy\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.36.0

[√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.1586] • Chrome (web) • chrome • web-javascript • Google Chrome 99.0.4844.82 • Edge (web) • edge • web-javascript • Microsoft Edge 99.0.1150.46

[√] HTTP Host Availability • All required HTTP hosts are available

Doctor found issues in 2 categories. `

I was running the code on Edge.

I removed the FlutterClipboard code and the same exception appeared, and I think it's because the list size exceeds a million items! Although the list was created and the list length was printed as shown in the screenshot.

I took a screenshot of the exception and attached it to the comment. I hope it will help you.

Exception snapshot


What was I trying to do? I was trying to print all the printable characters in ASCII code. Even after trying to print the characters in small numbers and showing them in the run console, there are many characters that don't look good like emojis for example because they have more than one value in the ASCII Code so I'd better convert them to Unicode instead of ASCII.

MAlazhariy avatar Mar 24 '22 14:03 MAlazhariy

I wasn't able to exactly reproduce the problem, but I did cause Android Studio to become unresponsive. I think trying to print a million-character string broke it. I did not get an exception but I had to force-quit Android Studio.

stevemessick avatar Mar 28 '22 18:03 stevemessick

I see this in your original report:

Caused by: java.lang.OutOfMemoryError: Java heap space

I probably have my IDE configured with enough memory to handle the string, and it was probably trying to print the string but I got tired of waiting for it to finish.

stevemessick avatar Mar 28 '22 18:03 stevemessick

@jacob314 I'm tempted to close this issue. Is this use-case something we want to encourage? The user is using a Flutter app to print a million characters to the console in the IDE.

stevemessick avatar Apr 19 '22 23:04 stevemessick

@jacob314 I'm tempted to close this issue. Is this use-case something we want to encourage? The user is using a Flutter app to print a million characters to the console in the IDE.

0410BDCD-DFE8-4A35-B5FB-54DB58FDFC7D

abdulrojakdev avatar Aug 12 '22 06:08 abdulrojakdev