Android Studio 无法在 OpenSUSE 上启动(打开的文件太多)

Posted

技术标签:

【中文标题】Android Studio 无法在 OpenSUSE 上启动(打开的文件太多)【英文标题】:Android Studio won't start on OpenSUSE (too many files open) 【发布时间】:2015-08-16 12:34:57 【问题描述】:

我已经有一段时间没有在 *** 上发帖了,如果我把它放在错误的地方,请原谅我,但问题是:

我最近为我比较新安装的 OpenSUSE 系统下载了 android Studio,已经安装了 openjdk-devel,每当我尝试启动 studio.sh 时,启动画面就会出现,大约 70% 是通过加载完成的,然后向控制台发送垃圾邮件:

[   7146]  ERROR - j.util.io.ResizeableMappedFile - /home/user/.AndroidStudio1.3/system/caches/names.dat.len (Too many open files) 
java.io.FileNotFoundException: /home/user/.AndroidStudio1.3/system/caches/names.dat.len (Too many open files)
	at java.io.FileOutputStream.open(Native Method)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:171)
	at com.intellij.util.io.ResizeableMappedFile$1.execute(ResizeableMappedFile.java:119)
	at com.intellij.util.io.ResizeableMappedFile$1.execute(ResizeableMappedFile.java:114)
	at com.intellij.openapi.util.io.FileUtilRt.doIOOperation(FileUtilRt.java:700)
	at com.intellij.util.io.ResizeableMappedFile.writeLength(ResizeableMappedFile.java:114)
	at com.intellij.util.io.ResizeableMappedFile.readLength(ResizeableMappedFile.java:164)
	at com.intellij.util.io.ResizeableMappedFile.<init>(ResizeableMappedFile.java:55)
	at com.intellij.util.io.PersistentBTreeEnumerator.<init>(PersistentBTreeEnumerator.java:82)
	at com.intellij.util.io.PersistentEnumeratorDelegate.<init>(PersistentEnumeratorDelegate.java:38)
	at com.intellij.util.io.PersistentStringEnumerator.<init>(PersistentStringEnumerator.java:53)
	at com.intellij.util.io.PersistentStringEnumerator.<init>(PersistentStringEnumerator.java:46)
	at com.intellij.util.io.PersistentStringEnumerator.<init>(PersistentStringEnumerator.java:32)
	at com.intellij.openapi.vfs.newvfs.persistent.FSRecords$DbConnection.init(FSRecords.java:244)
	at com.intellij.openapi.vfs.newvfs.persistent.FSRecords$DbConnection.init(FSRecords.java:319)
	at com.intellij.openapi.vfs.newvfs.persistent.FSRecords$DbConnection.init(FSRecords.java:319)
	at com.intellij.openapi.vfs.newvfs.persistent.FSRecords$DbConnection.init(FSRecords.java:319)
	at com.intellij.openapi.vfs.newvfs.persistent.FSRecords$DbConnection.init(FSRecords.java:319)
	at com.intellij.openapi.vfs.newvfs.persistent.FSRecords$DbConnection.init(FSRecords.java:319)
	at com.intellij.openapi.vfs.newvfs.persistent.FSRecords$DbConnection.init(FSRecords.java:319)
	at com.intellij.openapi.vfs.newvfs.persistent.FSRecords$DbConnection.init(FSRecords.java:319)
	at com.intellij.openapi.vfs.newvfs.persistent.FSRecords$DbConnection.init(FSRecords.java:319)
	at com.intellij.openapi.vfs.newvfs.persistent.FSRecords$DbConnection.init(FSRecords.java:319)
	at com.intellij.openapi.vfs.newvfs.persistent.FSRecords$DbConnection.connect(FSRecords.java:160)
	at com.intellij.openapi.vfs.newvfs.persistent.FSRecords.connect(FSRecords.java:518)
	at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.initComponent(PersistentFSImpl.java:89)
	at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter$1.getComponentInstance(ComponentManagerImpl.java:568)
	at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:610)
	at com.intellij.util.pico.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:245)
	at com.intellij.util.pico.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:211)
	at org.picocontainer.defaults.BasicComponentParameter.resolveInstance(BasicComponentParameter.java:77)
	at org.picocontainer.defaults.ComponentParameter.resolveInstance(ComponentParameter.java:114)
	at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getConstructorArguments(ConstructorInjectionComponentAdapter.java:257)
	at org.picocontainer.defaults.ConstructorInjectionComponentAdapter$1.run(ConstructorInjectionComponentAdapter.java:217)
	at org.picocontainer.defaults.ThreadLocalCyclicDependencyGuard.observe(ThreadLocalCyclicDependencyGuard.java:53)
	at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:248)
	at com.intellij.util.pico.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:58)
	at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter$1.getComponentInstance(ComponentManagerImpl.java:550)
	at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:610)
	at com.intellij.util.pico.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:245)
	at com.intellij.util.pico.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:211)
	at org.picocontainer.defaults.CollectionComponentParameter.getArrayInstance(CollectionComponentParameter.java:268)
	at org.picocontainer.defaults.CollectionComponentParameter.resolveInstance(CollectionComponentParameter.java:127)
	at org.picocontainer.defaults.ComponentParameter.resolveInstance(ComponentParameter.java:116)
	at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getConstructorArguments(ConstructorInjectionComponentAdapter.java:257)
	at org.picocontainer.defaults.ConstructorInjectionComponentAdapter$1.run(ConstructorInjectionComponentAdapter.java:217)
	at org.picocontainer.defaults.ThreadLocalCyclicDependencyGuard.observe(ThreadLocalCyclicDependencyGuard.java:53)
	at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:248)
	at com.intellij.util.pico.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:58)
	at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter$1.getComponentInstance(ComponentManagerImpl.java:550)
	at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:610)
	at com.intellij.util.pico.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:245)
	at com.intellij.util.pico.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:211)
	at com.intellij.openapi.components.impl.ComponentManagerImpl.getComponentFromContainer(ComponentManagerImpl.java:168)
	at com.intellij.openapi.application.impl.ApplicationImpl.getComponentFromContainer(ApplicationImpl.java:533)
	at com.intellij.openapi.components.impl.ComponentManagerImpl.getComponent(ComponentManagerImpl.java:199)
	at com.intellij.openapi.components.impl.ComponentManagerImpl.getComponent(ComponentManagerImpl.java:194)
	at com.intellij.openapi.vfs.VirtualFileManager.getInstance(VirtualFileManager.java:44)
	at com.intellij.openapi.vfs.LocalFileSystem$LocalFileSystemHolder.<clinit>(LocalFileSystem.java:40)
	at com.intellij.openapi.vfs.LocalFileSystem.getInstance(LocalFileSystem.java:44)
	at com.intellij.openapi.components.impl.stores.ApplicationStoreImpl$1.beforeFileBasedStorageCreate(ApplicationStoreImpl.java:85)
	at com.intellij.openapi.components.impl.stores.StateStorageManagerImpl.createFileStateStorage(StateStorageManagerImpl.java:212)
	at com.intellij.openapi.components.impl.stores.StateStorageManagerImpl.createStateStorage(StateStorageManagerImpl.java:185)
	at com.intellij.openapi.components.impl.stores.StateStorageManagerImpl.getStateStorage(StateStorageManagerImpl.java:102)
	at com.intellij.openapi.components.impl.stores.ComponentStoreImpl.initPersistentComponent(ComponentStoreImpl.java:315)
	at com.intellij.openapi.components.impl.stores.ComponentStoreImpl.initComponent(ComponentStoreImpl.java:75)
	at com.intellij.openapi.application.impl.ApplicationImpl.initializeComponent(ApplicationImpl.java:177)
	at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter$1.getComponentInstance(ComponentManagerImpl.java:566)
	at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:610)
	at com.intellij.util.pico.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:245)
	at com.intellij.util.pico.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:211)
	at com.intellij.openapi.components.impl.ComponentManagerImpl.createComponent(ComponentManagerImpl.java:125)
	at com.intellij.openapi.application.impl.ApplicationImpl.createComponent(ApplicationImpl.java:354)
	at com.intellij.openapi.components.impl.ComponentManagerImpl.createComponents(ComponentManagerImpl.java:116)
	at com.intellij.openapi.components.impl.ComponentManagerImpl.init(ComponentManagerImpl.java:87)
	at com.intellij.openapi.components.impl.stores.ApplicationStoreImpl.load(ApplicationStoreImpl.java:101)
	at com.intellij.openapi.application.impl.ApplicationImpl.load(ApplicationImpl.java:499)
	at com.intellij.openapi.application.impl.ApplicationImpl.load(ApplicationImpl.java:481)
	at com.intellij.idea.IdeaApplication.run(IdeaApplication.java:170)
	at com.intellij.idea.MainImpl$1$1$1.run(MainImpl.java:52)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:745)
	at java.awt.EventQueue.access$300(EventQueue.java:103)
	at java.awt.EventQueue$3.run(EventQueue.java:706)
	at java.awt.EventQueue$3.run(EventQueue.java:704)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:715)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:362)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
[   7150]  ERROR - j.util.io.ResizeableMappedFile - Android Studio 1.3.1  Build #AI-141.2135290 
[   7151]  ERROR - j.util.io.ResizeableMappedFile - JDK: 1.7.0_85 
[   7151]  ERROR - j.util.io.ResizeableMappedFile - VM: OpenJDK Server VM 
[   7151]  ERROR - j.util.io.ResizeableMappedFile - Vendor: Oracle Corporation 
[   7151]  ERROR - j.util.io.ResizeableMappedFile - OS: Linux 

我有点不知所措了。我已经尝试链接到 openjdk 以及 Oracle 的最新 JDK 版本。我尝试过使用最大打开文件的数量(在 /etc/environment/limits.conf 中设置),但尽管错误表明打开的文件很多,但这似乎没有任何作用。我已经尝试升级到 openjdk1.8,降级到 1.7,多次重新安装所有内容,但我似乎无法启动它。

这是一个合法的错误还是严重的用户错误?关于我可以在哪里解决这个问题的任何想法?

编辑: /etc/environment/limits.conf

# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain>        <type>  <item>  <value>
#
#Where:
#<domain> can be:
#        - a user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#        - the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#
#<type> can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
#<item> can be one of the following:
#        - core - limits the core file size (KB)
#        - data - max data size (KB)
#        - fsize - maximum filesize (KB)
#        - memlock - max locked-in-memory address space (KB)
#        - nofile - max number of open files
#        - rss - max resident set size (KB)
#        - stack - max stack size (KB)
#        - cpu - max CPU time (MIN)
#        - nproc - max number of processes
#        - as - address space limit (KB)
#        - maxlogins - max number of logins for this user
#        - maxsyslogins - max number of logins on the system
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#        - sigpending - max number of pending signals
#        - msgqueue - max memory used by POSIX message queues (bytes)
#        - nice - max nice priority allowed to raise to values: [-20, 19]
#        - rtprio - max realtime priority
#
#<domain>      <type>  <item>         <value>
#

#*               soft    core            0
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4

* hard nofile 65535
* soft nofile 65535
root soft nofile 65535
root hard nofile 65535

# End of file

uname -a

Linux susebart 3.16.7-21-desktop #1 SMP PREEMPT Tue Apr 14 07:11:37 UTC 2015 (93c1539) i686 i686 i386 GNU/Linux

cat /proc/version

Linux version 3.16.7-21-desktop (geeko@buildhost) (gcc version 4.8.3 20140627 [gcc-4_8-branch revision 212064] (SUSE Linux) ) #1 SMP PREEMPT Tue Apr 14 07:11:37 UTC 2015 (93c1539)

以下是 shell 的一些神秘输出:

$ whoami
corey
$ ulimit -Hn
256
$ ulimit -Sn
256
$ su 
$ whoami
root
$ ulimit -Hn
65535
$ ulimit -Sn
65535
$ su corey
$ whoami
corey
$ ulimit -Hn
65535
$ ulimit -Sn
65535
$ exit
$ exit // getting back to login shell
$ whoami
corey
$ ulimit -Hn
256
$ ulimit -Sn
256

因此,当打开一个新的 shell 时(即使在上面嵌套的 su 的情况下没有先切换到 root),看起来限制已经正确更改,但在机器启动或打开新 shell 时没有。我确认通过运行 su USERNAME ./studio.sh 我终于能够启动程序,所以至少这是一种解决方法。任何线索都与 shell 实例发生了什么?

【问题讨论】:

根据this、this 和this,您应该不止一处调整此类设置。您是否尝试过重新启动系统? ulimit -Hn 当前显示什么,您的旧限制还是新限制? 我修改了额外的文件并按照链接的说明重新启动,但 ulimit -Hn / -Sn 始终显示 256。即使运行 sudo bash -c "ulimit -n 50000" 也不会改变它。如果我尝试附加脚本来启动 Android Studio 可执行文件,它会返回:“启动错误:无法检测图形环境” 好的,请将您当前的/etc/security/limits.conf 添加到问题中,请告诉我,如果您检查ulimit -a,是否会应用新设置重启之前?还请添加您的uname -acat /proc/version 结果,也许这确实是特定 OpenSUSE 版本中的某种错误(我在我的 OS X 和 Fedora 18 上检查了您的情况 - 一切看起来都很好:) 编辑了答案。 ulimit -a 不应用设置。我会认为limits.conf有问题吗? 看,我在limits.conf 中做了同样的事情,这里是输出before reboot: pastebin.com/GtAm7iMG 这是after reboot :pastebin.com/vrwFdTUw 我不确定你是否在根目录下进行了所有这些修改,是吗?也许这是个愚蠢的问题,但我想确定一下,因为几乎不可能不应用在 root 用户下所做的更改。 【参考方案1】:

至于现在是这样的:

$ whoami        //session 1 (256)
corey
$ ulimit -Hn
256
$ ulimit -Sn
256
$ su            //session 2 (65k)
$ whoami
root
$ ulimit -Hn
65535
$ ulimit -Sn
65535
$ su corey      //session 3 (65k)
$ whoami
corey
$ ulimit -Hn
65535
$ ulimit -Sn
65535
$ exit      //session 2(65k)
$ exit     // getting back to login shell: session 1 (256)
$ whoami
corey
$ ulimit -Hn
256
$ ulimit -Sn
256

su 命令可以更改登录会话的所有者(即最初通过登录系统创建该会话的用户)所有者不必先注销那个会议。 因此,当您注销 2 次(从 root 和 corey 会话)时,您会返回到您的旧限制似乎有效的初始会话。我不知道如果您正确地重新启动系统会发生这种情况,所以我只是建议您在corey重新登录(意味着明确注销并登录),我打赌来自limits.conf 的新值应该最终申请。

【讨论】:

显式注销并重新登录不会改变任何事情;我仍然必须自我调整才能适用这些限制。我不知道这是发行版中的错误还是我搞砸了,但我接受这个答案只是因为你给了我一个可用的解决方法。 好吧,在阅读danwalsh.livejournal.com/62070.html 之后——看看错误 #2,我开始认为您的问题可能出在 SELinux 策略中(这只是一个猜测,但请尝试禁用 SELinux 并查看是什么发生了)

以上是关于Android Studio 无法在 OpenSUSE 上启动(打开的文件太多)的主要内容,如果未能解决你的问题,请参考以下文章

Android studio从相册里面选图片无法选中

Android:无法在 android studio 中打开 eclipse 项目

android studio怎么联网

无法在 Android Studio 中安装 Android SDK

无法解析 Android Studio 中的依赖项

无法在 android (Android studio) 中测试受保护的方法