0

我遇到了著名的“打开的文件太多”问题,并试图找出我的应用程序打开了哪些文件。看来要怪的是MapKit!

我在 iOS 6 模拟器中运行了我的应用程序,并打开了 "Debug > Location > Freeway Drive"。然后用来lsof -i | grep MyAppName获取打开的 TCP 连接。这就是我得到的:

iWasteBul 36816 ivanzhu    1u  IPv4 0xf7ae68a3a8b239af      0t0  TCP localhost:49504->localhost:49503 (ESTABLISHED)
iWasteBul 36816 ivanzhu    2u  IPv4 0xf7ae68a3a8b239af      0t0  TCP localhost:49504->localhost:49503 (ESTABLISHED)
iWasteBul 36816 ivanzhu    4u  IPv4 0xf7ae68a3a8b239af      0t0  TCP localhost:49504->localhost:49503 (ESTABLISHED)
iWasteBul 36816 ivanzhu    5u  IPv4 0xf7ae68a3a849b407      0t0  TCP localhost:49505->localhost:49503 (ESTABLISHED)
iWasteBul 36816 ivanzhu    6u  IPv4 0xf7ae68a3a62634ff      0t0  TCP localhost:49506->localhost:49503 (ESTABLISHED)
iWasteBul 36816 ivanzhu   30u  IPv4 0xf7ae68a3a84350e7      0t0  TCP 192.168.1.108:50151->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   31u  IPv4 0xf7ae68a3a939f407      0t0  TCP 192.168.1.108:50148->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   32u  IPv4 0xf7ae68a3a939f407      0t0  TCP 192.168.1.108:50148->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   33u  IPv4 0xf7ae68a3a3482f57      0t0  TCP 192.168.1.108:50149->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   34u  IPv4 0xf7ae68a3a3482f57      0t0  TCP 192.168.1.108:50149->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   35u  IPv4 0xf7ae68a3a8540277      0t0  TCP 192.168.1.108:50150->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   36u  IPv4 0xf7ae68a3a8540277      0t0  TCP 192.168.1.108:50150->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   37u  IPv4 0xf7ae68a3a84350e7      0t0  TCP 192.168.1.108:50151->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   38u  IPv4 0xf7ae68a3a89f468f      0t0  TCP 192.168.1.108:50157->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   39u  IPv4 0xf7ae68a3a89f3f57      0t0  TCP 192.168.1.108:50152->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   40u  IPv4 0xf7ae68a3a89f3f57      0t0  TCP 192.168.1.108:50152->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   41u  IPv4 0xf7ae68a3a75bcdc7      0t0  TCP 192.168.1.108:50153->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   42u  IPv4 0xf7ae68a3a75bcdc7      0t0  TCP 192.168.1.108:50153->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   43u  IPv4 0xf7ae68a3a90729af      0t0  TCP 192.168.1.108:50154->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   44u  IPv4 0xf7ae68a3a90729af      0t0  TCP 192.168.1.108:50154->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   45u  IPv4 0xf7ae68a3a94b2ccf      0t0  TCP 192.168.1.108:50155->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   46u  IPv4 0xf7ae68a3a94b2ccf      0t0  TCP 192.168.1.108:50155->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   47u  IPv4 0xf7ae68a3a4eac0e7      0t0  TCP 192.168.1.108:50156->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   48u  IPv4 0xf7ae68a3a4eac0e7      0t0  TCP 192.168.1.108:50156->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   49u  IPv4 0xf7ae68a3a89f468f      0t0  TCP 192.168.1.108:50157->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   50u  IPv4 0xf7ae68a3a94754ff      0t0  TCP 192.168.1.108:50167->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   51u  IPv4 0xf7ae68a3a849accf      0t0  TCP 192.168.1.108:50158->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   52u  IPv4 0xf7ae68a3a849accf      0t0  TCP 192.168.1.108:50158->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   53u  IPv4 0xf7ae68a3a76c868f      0t0  TCP 192.168.1.108:50159->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   55u  IPv4 0xf7ae68a3a76c868f      0t0  TCP 192.168.1.108:50159->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   56u  IPv4 0xf7ae68a3a66a1277      0t0  TCP 192.168.1.108:50160->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   57u  IPv4 0xf7ae68a3a66a1277      0t0  TCP 192.168.1.108:50160->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   58u  IPv4 0xf7ae68a3a93d7f57      0t0  TCP 192.168.1.108:50161->123.103.0.159-bj-cnc:https (ESTABLISHED)
iWasteBul 36816 ivanzhu   59u  IPv4 0xf7ae68a3a93d7f57      0t0  TCP 192.168.1.108:50161->123.103.0.159-bj-cnc:https (ESTABLISHED)

而且该列表不断增长,以至于我的代码在尝试写入文件时开始出现“打开的文件过多”错误。

我在 iOS 5.1 模拟器上做了同样的测试,看起来还不错(没有额外的连接):

iWasteBul 37547 ivanzhu    1u  IPv4 0xf7ae68a3a8a00dc7      0t0  TCP localhost:51490->localhost:51489 (ESTABLISHED)
iWasteBul 37547 ivanzhu    2u  IPv4 0xf7ae68a3a8a00dc7      0t0  TCP localhost:51490->localhost:51489 (ESTABLISHED)
iWasteBul 37547 ivanzhu    4u  IPv4 0xf7ae68a3a8a00dc7      0t0  TCP localhost:51490->localhost:51489 (ESTABLISHED)
iWasteBul 37547 ivanzhu    5u  IPv4 0xf7ae68a3a8a0cdc7      0t0  TCP localhost:51491->localhost:51489 (ESTABLISHED)
iWasteBul 37547 ivanzhu    6u  IPv4 0xf7ae68a3a8a014ff      0t0  TCP localhost:51492->localhost:51489 (ESTABLISHED)

为了确保这不是我的应用程序的问题,我杀死了模拟器中所有正在运行的应用程序,启动内置的“地图”应用程序,并得到了相同的结果。但我无法在 iOS 5.1 模拟器中进行相同的测试,因为其中没有安装“地图”应用程序。

我的问题是:

  1. 我是否使用正确的工具来打开 TCP 连接?
  2. 它是 iOS 6 模拟器(和潜在的设备)中的错误吗?
  3. 如何处理?

任何帮助表示赞赏!

4

1 回答 1

0

Ivan,我可以告诉你它存在于 iOS 6.0.1 中。我运行一个论坛,每天几次,我收到来自服务器的 DDoS 保护模块的电子邮件,某某 IP 被“阻止太多连接”,50 或更多但通常接近 80。

这些人之间唯一的共同点是他们使用的是运行 iOS 6.0.1 的 iPad。我只看到了一个 6.0.2 连接,因此无法验证问题是否在 6.0.2 中得到解决。

于 2013-01-06T03:01:06.517 回答