V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
anexplore
V2EX  ›  Java

apache httpasyncclient 的 direct memory 内存一直增长,直到 oom

  •  
  •   anexplore · 2015-09-08 18:34:16 +08:00 · 3103 次点击
    这是一个创建于 3124 天前的主题,其中的信息可能已经有所发展或是发生改变。
    使用 4.1 版本,使用过程中发现, direct memory 会间歇性不断增长,直到 oom ,有同学遇到类似情况吗?
    具体帖子: http://stackoverflow.com/questions/32454031/httpasyncclient-outofmemoryerror-direct-buffer-memory

    jdk 版本 1.8
    6 条回复    2015-09-09 13:12:24 +08:00
    armstrong
        1
    armstrong  
       2015-09-08 19:24:29 +08:00   ❤️ 2
    如果可以换 http 库的话,推荐楼主用 OkHttp ,比 Apache Common 系列的 HttpClient 好用多了,附链接: https://github.com/square/okhttp/wiki/Recipes
    anexplore
        2
    anexplore  
    OP
       2015-09-08 19:40:41 +08:00
    @armstrong 这个可以方便的自己控制跳转吗?比如控制最大跳转次数,拿到每次跳转的 HTTP 头
    unique
        3
    unique  
       2015-09-08 20:40:27 +08:00 via Android   ❤️ 1
    七牛的 java sdk 也用的 okhttp
    fwrq41251
        4
    fwrq41251  
       2015-09-09 09:33:53 +08:00
    @armstrong 好在哪里能简单说一下吗
    armstrong
        5
    armstrong  
       2015-09-09 13:10:46 +08:00   ❤️ 1
    @fwrq41251 首先在 api 变动这块, Apache Common 的 HttpClient 各个版本之间的 api 变化太大,而 OKHttp 则没有这个问题而且更简洁,这块是我使用时最直观的感受。剩下的优点直接看这个吧 http://lzyblog.com/2014/10/30/Square%E5%BC%80%E6%BA%90%E5%BA%93OkHttp%E7%9A%84%E5%88%86%E6%9E%90%E5%92%8C%E4%BD%BF%E7%94%A8%EF%BC%88%E4%B8%80%EF%BC%89/
    armstrong
        6
    armstrong  
       2015-09-09 13:12:24 +08:00
    @anexplore 不太清楚你的需求,不过 OkHttp 使用很简单,你自己测一下就知道了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1073 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:12 · PVG 03:12 · LAX 12:12 · JFK 15:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.