- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 .NET 框架中的 GZipStream 类压缩一些数据包。一切正常,压缩率也不错,但是当我使用十六进制编辑器查看压缩数据时,我注意到每个压缩数据包中有多达三分之一是尾随零。这正常吗?
大概 GZipStream 是一个基于 block 的压缩器并且输出被填充以与一些 block 大小对齐?是否有一些同样稳定、得到支持但没有这个问题的替代品? (我认为通过使用不会过度填充的类似压缩算法,我可以再获得 10-30% 的压缩率)。
最佳答案
使用 GZipStream
不应添加过多的尾随零。
但是如果你使用 MemoryStream
不正确,它会导致这种效果。它在内部使用 byte[]
来存储数据。这个内部缓冲区可以比目前写入的数据大,以减少分配次数。如果你使用 GetBuffer()
你得到了完整的数组,你自己有责任只使用它的第一个 Length
字节。
或者您可以调用 ToArray()
它返回一个新的字节数组,正好包含 Length
个字节。
引用 GetBuffer()
的文档:
Note that the buffer contains allocated bytes which might be unused. For example, if the string
"test"
is written into theMemoryStream
object, the length of the buffer returned fromGetBuffer
is 256, not 4, with 252 bytes unused. To obtain only the data in the buffer, use theToArray
method; however,ToArray
creates a copy of the data in memory.
关于.net - 什么会导致 GZipStream 压缩数据过多地填充零?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21291263/
我在 JBoss 6 上使用 JSF 2。我制作了一个示例应用程序,它使用 JSF 作为 View ,使用 EJB 作为逻辑,使用 JPA 作为持久性。 JSF 中的 bean 具有 RequestS
我打开气流并检查了连接,然后发现背后有太多连接。 关于如何杀死那些我不使用的想法,或者我很想知道运行它的最低conn_id的任何想法。 建筑 LocalExecutor(与其他经纪人不同) Postg
我收到错误 style.css:1 GET https://www.example.com/cs_CZ净::ERR_TOO_MANY_REDIRECTS 可能与我的 htaccess 有关吗? Rew
我收到错误 style.css:1 GET https://www.example.com/cs_CZ净::ERR_TOO_MANY_REDIRECTS 可能与我的 htaccess 有关吗? Rew
我正在 Android 中开发一个应用程序,我有以下 XML 布局:
我有 5 个类用作运算符: TurnOn , TurnOff , PushBox , Exit , Enter 对于每种类型,我都有一个包含该类型描述的字符串。 例如: class Places {
我们在使用 lettuce redis 库时遇到了这个具体问题。我们收到太多 RedisCommandTimeoutException。我们在 redis-cli 中设置了 2 秒的超时,在 redi
在 Controller 类文件中,大多数方法函数都包含try/catch块,如下所示: try { $stmt = $this->prepare($sql); $st
我读到这个page附加很多元素是不好的做法,我应该在循环的每次迭代期间构建一个字符串,然后将 DOM 元素的 HTML 设置为该字符串。在循环中使用过多的 HTML 是否也是如此? 我有一个解析 JS
在我的应用程序日志上运行 logcat 时,我看到很多 GC_FOR_ALLOC 而没有 GC_CONCURRENT 消息。我知道我有内存泄漏,但在堆栈和其他站点的任何地方,logcat 消息都有很多
当我检查我的 Tomcat 应用程序管理器时,我发现我的 session 太多(超过 4600): 为什么会这样?这可以链接到已部署的应用程序,还是它已经运行了很长时间? 最佳答案 这可能有多种原因,
所以我试图在一个 div 中运行 3 个 float ,但我遇到了这个问题。 http://jsfiddle.net/sPUjQ/101/ 点我 每当我运行两次 float 时,背景颜色会保持不变,但
为什么在使用 http_build_query 函数构建查询字符串时,它会将方括号 [] urlencode 到值之外,如何摆脱它? $query = array("var" => array("fo
在一个过程中,我需要使用许多 if-else 条件来决定列的值。该脚本以 FOR rec IN (SELECT....) LOOP Begin 并决定许多不同的值 rec 子记录可以在每次迭代中获得。
我们基于 Java 的服务器应用程序报告异常长的类加载时间: # jstat -class 10625 1000 Loaded Bytes Unloaded Bytes Time 4
我正在使用 Kraken.js 开发一个应用程序并管理我决定使用的 session :connect-mongo。 我有这样的设置: 'use strict'; var session = requi
我在 iPad 应用程序中有 180 个 UILabels(UITableViewCells 的 subview ),每个 UILabel 的宽度为 155 X 155,并且每个包含大量 Unicod
所以基本上,如果我将 JPanel 放入使用 GridBagLayout 的 JPanel 中,并使用 setPreferredSize 限制大小>,最终它达到了无法容纳所有这些的地步,并且它表现出附
我目前使用的是 Play 2.2.1,在白天运行生产 Web 应用程序后,我的日志中开始出现以下错误。似乎我的连接已用完/我一定没有正确关闭某些东西,但我似乎无法弄清楚它是什么。 2014-02-11
所以我几乎完成了我的元素,我打算创建一个完整的网页 slider 作为我网站的背景主题,并且它运行完美! 问题是它的垂直拉伸(stretch)太长,您可以向右滚动(您不应该那样做)而且我不知道为什么它
我是一名优秀的程序员,十分优秀!