【日常问题记录】Android Studio 运行报错 ( There is not enough memory to perform the requested operation. )

昨天写代码写到一半,Android Studio突然卡死。强制重启后,出现弹框There is not enough memory to perform the requested operation.

e927bc71f0324cfd970e7936108ad1cf.png

将弹框中配置的Xmx改得更大,重启Android Studio后,仍然显示这个弹框。

最终,把自己刚写的代码用tower工具回滚,发现解决问题。

根源问题:

@JvmStatic
    fun covertEntityToBook(bookEntity: BookEntity?): BookModel? {
        if (bookEntity == null) {
            return null
        }
        val bookModel = BookModel()

        bookModel.category_index = bookEntity.categoryIndex}
    }

bookModel.category_index = bookEntity.categoryIndex}
这句代码当时写快了,先打了"}"没写双引号、“{”, Android Studio在自身编绎kotlin代码时,在这句话上出现了死循环,导致OOM。

通过除了Android Studio之外的其他文件编辑工具(比如sublime)将这行代码改正确,重启Android Studio,即可解决问题。

bookModel.category_index = "${bookEntity.categoryIndex}"

你可能感兴趣的:(【日常问题记录】Android Studio 运行报错 ( There is not enough memory to perform the requested operation. ))