In the process of creating @Preview with Android Compose, a rendering error occurred with the following warning:
java.lang.OutOfMemoryError: Cannot reserve 2712356 bytes of direct buffer memory (allocated: 313023239, limit: 314572800)
at java.nio.Bits.reserveMemory
at java.nio.DirectByteBuffer.<init>
at java.nio.ByteBuffer.allocateDirect
at android.graphics.fonts.Font_Builder_Delegate.createBuffer(Font_Builder_Delegate.java:53)
at android.graphics.fonts.Font$Builder.createBuffer(Font.java:264)
at android.graphics.fonts.Font$Builder.<init>(Font.java:228)
at androidx.core.graphics.TypefaceCompatApi29Impl.createFromResourcesFontFile(TypefaceCompatApi29Impl.java:171)
...
I think this error occurs because the use of fontFamily used in Compose Text exceeds the allocated memory, but I don't know how to solve the problem.
Because only the absolutely necessary text is written and the necessary fonts are applied, the number of texts cannot be reduced. Is there no other answer than increasing the allocated memory usage?