zlib error while attempting compression: "Ran out of output buffer for writing compressed bytes."
来源:互联网 发布:co网络用语是什么意思 编辑:程序博客网 时间:2024/05/24 06:19
gzip算法
使用Object-C代码来实现gzip的压缩功能,不管网上找的哪个地方的代码,方法都是一样的
- https://github.com/cscott530/sprite-kit-platformer/blob/master/SuperKoalio/LFCGzipUtility.m
- http://www.clintharris.net/2009/how-to-gzip-data-in-memory-using-objective-c/
- http://v2it.win/ios/gzip%E6%96%87%E4%BB%B6%E5%8E%8B%E7%BC%A9%E5%92%8C%E8%A7%A3%E5%8E%8B%E7%BC%A9/
在使用大的数据进行gzip压缩时,一切正常,但是使用小的数据,比如几个字节,这是就会出现以下的错误:
zlib error while attempting compression: "Ran out of output buffer for writing compressed bytes."
错误的原因是buffer空间不够。
我们来看下压缩的代码:
gzip压缩时,分配的压缩后的数据空间大小为: 1.01倍 + 12.
// Create output memory buffer for compressed data. The zlib documentation states that
// destination buffer size must be at least 0.1% larger than avail_in plus 12 bytes.
NSMutableData compressedData = [NSMutableData dataWithLength:[pUncompressedData length]1.01 + 12];
针对小的数据,这个大小远远不够,如果改成 10倍 + 12,可以正常gzip压缩,具体的临界值是多少还没去仔细研究:
参考:
1. http://www.jianshu.com/p/a0c94dc75efc
0 0
- zlib error while attempting compression: "Ran out of output buffer for writing compressed bytes."
- zlib error while attempting compression: "Ran out of output buffer for writing compressed bytes."
- Error: Ran out of space in ROM for simsun.ac3
- EOFError: Ran out of input
- UBI error: ubi_io_write: error -5 while writing 512 bytes to PEB 60:512, wri
- SurfaceFlinger/gralloc Out of Memory error when allocating buffer memory for use with virtual frame
- apt error:E: Dynamic MMap ran out of room。如何解决?
- keil for stm32中出现的警告" integer operation result is out of ran"
- Dynamic MMap ran out of room
- Python error:compression requires zlib module
- php中ob_gzhandler' conflicts with 'zlib output compression问题
- Not enough space svn: zlib (uncompress): buffer error: Decompression of svndiff data failed
- PHP Warning: ob_start() : output handler 'ob_gzhandler conflicts with 'zlib output compression'
- PHPCMS安装提示output handler 'ob_gzhandler' conflicts with 'zlib output compression'
- apt-get: Dynamic MMap ran out of room的解决方法
- ubuntu 10.04 E: Dynamic MMap ran out of room 解决方案
- 数据库读取错误:ran out of memory retrieving query results
- SignTool Error: An error occurred while attempting to sign
- Android App包瘦身优化实践
- 文章标题
- python获取交互式ssh shell
- DOM的三大结点:元素结点、文本结点、属性结点
- 关于androidpulltorefresh
- zlib error while attempting compression: "Ran out of output buffer for writing compressed bytes."
- WebRTC中RTP/RTCP协议实现分析
- 视频编码会议常用网址
- 关于js中动态生成的点击事件触发两次的讨论
- Base64编码在客户端与服务器传值问题
- 如何让Eclipse的启动速度加快
- bootstrap-file-input使用心得
- SpringMVC 基本配置文件
- Android onMeasure、Measure、measureChild、measureChildren 一些简要说明