我遇到了着名的「太多打開文件」的問題,並試圖找出哪些文件被我的應用程序打開。看起來這是MapKit應該受到指責!iOS 6地圖使用了太多的TCP連接?
我在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模擬器相同的測試,它看起來OK(無需額外連接):
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模擬器中進行相同的測試,因爲沒有安裝「Maps」應用程序。
我的問題是:
- 我使用正確的工具來獲得打開的TCP連接?
- 它是iOS 6模擬器(和潛在的設備)中的錯誤?
- 如何處理?
任何幫助表示讚賞!
嗨詹姆斯,感謝您的回覆。但我不確定我們是否在這裏談論同樣的問題。我的文章中的TCP連接顯然是由MKMapView試圖從Apple地圖服務器檢索地圖圖塊生成的。如果MKMapView從應用程序中刪除,一切都會恢復正常。 – IvanZ
常見的問題是,iOS6打開了過多的端口數量到目標服務器,而不是2-5,並將它們重複用於其他請求(遵循Http/1.0而不是Http/1.1)。 我不認識蘋果公司的任何人抱怨,並且一位朋友的朋友說蘋果在這裏檢查,所以我希望你和我的相似程度足以讓蘋果公司注意並修復。 :) – James