- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在使用以下代码计算对象(正在填充的列表)的大小:
long myObjectSize = 0;
System.IO.MemoryStream memoryStreamObject = new System.IO.MemoryStream();
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter binaryBuffer = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
binaryBuffer.Serialize(memoryStreamObject, myListObject);
myObjectSize = memoryStreamObject.Position;
memoryStreamObject
的初始容量为 1024
而且它似乎随着流内容的增加而增加。那么这个场景下容量的作用是什么?
最佳答案
这是MemoryStream内部实现造成的。 Capacity 属性是内部缓冲区的大小。如果使用固定大小的缓冲区创建 MemoryStream,这是有意义的。但在您的情况下,如果缓冲区太小,MemoryStream 可能会增长,并且实际实现会使缓冲区的大小加倍。
内存流代码
private bool EnsureCapacity(int value)
{
if (value < 0)
{
throw new IOException(Environment.GetResourceString("IO.IO_StreamTooLong"));
}
if (value > this._capacity)
{
int num = value;
if (num < 256)
{
num = 256;
}
if (num < this._capacity * 2)
{
num = this._capacity * 2;
}
if (this._capacity * 2 > 2147483591)
{
num = ((value > 2147483591) ? value : 2147483591);
}
this.Capacity = num;
return true;
}
return false;
}
在 Write 的某处
int num = this._position + count;
// snip
if (num > this._capacity && this.EnsureCapacity(num))
关于c# - 什么定义了内存流的容量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32985374/
我在 iOS 上有一个使用 WebSQL 数据库的 PhoneGap 应用程序。在某些地方,我读到存储容量是 5MB,而在其他地方,我读到它是 50MB,有人可以帮我解决这个问题吗?我还计划在数据库中
我想弄清楚如何更新节点的 pod 容量。我使用文档中概述的 Vagrant/VM 环境进行了简单的集群设置。我尝试使用 kubectl 修补节点的 pod 容量,执行以下操作: 通过以下方式发送补丁所
我想创建一个函数,根据某人系统上的可用 RAM 大小来导入不同批处理的数据。但是如何找到 R 中的可用 RAM 量呢?我可以使用 memory.size() 但这只适用于 Windows。 最佳答案
目前,我正在努力将 Power BI 内容嵌入到我的 Web 应用程序中。我已经通过服务主体实现了它,并且它按预期工作。但是对于产品环境,是否必须为我的报告或工作区添加容量?是否可以在不增加生产环境容
我有一个 3 节点 coros kubernetes 集群启动并运行。 我想使用来自独立 NFS 服务器的 persitentvolumes(pv)。 nfs.yaml apiVersion: v1
我正在学习golang一段时间。我遇到了 channel 问题。 我有两个例子。它们看起来一样,但是其中1个给出了错误。 当我分配 channel 容量(转换为缓冲 channel )时,问题已解决,
我正在尝试创建一个子例程,将一个字符串插入另一个字符串。我想检查主机字符串是否有足够的容量来容纳所有字符,如果没有,则返回错误整数。这需要使用类似 sizeof 的东西,但可以使用指针调用。我的代码如
这个问题在这里已经有了答案: size vs capacity of a vector? (8 个答案) 关闭 7 年前。 在下面的程序中,我只是创建了一个空 vector ,然后将大小调整为 5
免责声明 1 - 我是编程新手免责声明 2 - 我搜索了又搜索,但找不到我正在寻找的帮助。 对于一个项目,我或多或少地以更精简的形式重写了 vector 类。我挂断的部分是编写 push_back 方
我对 BTree 的理解是: if root BTree size is 32, the level 1 have 1024 keys capacity the level 2 can sort 10
我有一个使用 ActionBar 的应用程序,我自己处理方向更改: android:configChanges="keyboard|keyboardHidden|orientation|screenS
如何将 hadoop DFS 的配置容量从默认的 50GB 增加到 100GB? 我目前的设置是在 centOS6 机器上运行的 hadoop 1.2.1,使用了 450GB 中的 120GB。已使用
我的问题是关于 slice 长度和容量。我在这里学习 Go:https://tour.golang.org/moretypes/11 . (我的问题被标记为可能与 this 重复;但是,事实并非如此。
现在尝试从教程中学习 Go,并且有一个非常基本的问题: func main() { a := make([]int, 5) // [0,0,0,0,0] len=5 cap=5 b :=
如何以以下格式获取有关数据库中所有表空间的信息。 TABLESPACE_NAME | FILE_NAME | ALLOCATED_MB | FREE_MB | CAPACITY | 有没有办法自
我想基于每个作业更改群集的减少插槽容量。也就是说, 最初,我为Tasktracker配置了8个reduce插槽,因此对于具有100个reduce任务的作业,将同时运行(8 * datanode数量)r
我正在运行单节点 Hadoop 部署。我知道我的应用程序需要多少数据,我可以设置(和重新设置)HDFS 使用的最大容量吗? 我已经尝试了以下方法,但似乎无法实现。 检查 hdfs-site.xml 和
我安装了 splunk 来监控和分析 hadoop 作业。我在其他节点的Jobtracker、forwarder和TA中安装splunk core和splunk hadoop app后,HDFS ca
vector::operator= 会改变 vector 容量吗?如果有,怎么做? vector的拷贝构造函数是否拷贝容量? 我查看了文档,但找不到具体答案。是否依赖于实现? 最佳答案 您可以保证:
将 SQL 数据库导出到存储时,我们的 DTU 容量已达到,这本质上意味着我们的系统性能受到严重影响。 这对我们来说是一个问题,因为我们使用导出功能来备份和移动数据库。 这个问题有解决办法吗? 最佳答
我是一名优秀的程序员,十分优秀!