在使用zlib压缩数据时,进行内存分配。

huangapple go评论75阅读模式
英文:

Memory allocation while zlib-compressing data?

问题

假设有10个线程并行运行,每个线程压缩100MB的数据。我正在使用zlib压缩算法来进行数据压缩。

假设一个进程需要大约2秒来压缩100MB的数据。那么如果所有线程都并行运行来压缩数据,会发生什么情况呢?

另外,我需要澄清一下每个线程的内存分配情况。

情况1:
假设有1GB的RAM内存,现在有10个线程并行运行来开始压缩数据,那么这个过程会占用全部的RAM内存吗?

 10个线程 * 100MB = 1000MB(约等于1GB)
英文:

Go:

Assume, there are 10 threads running in parallel to compress the 100 MB of data each. For each and every thread going to compress 100 MB of data. I am using zlib compression to compress the data.

Consider one process took nearly 2 sec to compress the 100 MB of data. So What happens if all the threads running parallel to compress the data.

And also i need clarification about Memory allocation for each thread.

Case 1:
having 1 GB RAM memory, Now the 10 threads going to run parallel to start the compression means , Whether it will take all the RAM Memory for the process of compression?

 10 Threads * 100 MB = 1000 (Approx)

答案1

得分: 3

zlib本身需要相对较少的内存,每个线程最多需要256kb。如果你将输入和输出保存在内存中,那么内存的主要消耗将来自于你用于存储输入和输出的内存。有关详细信息,请参阅zlib网站(查找“内存占用”主题)。

英文:

zlib itself will need a relatively trivial amount of memory, up to 256kb per thread. This will be dominated by the memory you use to store your input and output, if you are keeping those in memory. For details, see the
zlib web site (Look for the "Memory Footprint" topic).

huangapple
  • 本文由 发表于 2016年2月2日 19:43:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/35152532.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定