INT列表内存大小 [英] Memory size of a list of int

查看:174
本文介绍了INT列表内存大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个是存储在数据库中的用逗号分隔字符串的形式之间为int的列表(4345,324,24,2424,64567,33 ...)。此字符串会变得非常大,并包含2-3万人的数字。它存储在数据库中,并经常用到。

I have a list of int that's stored in the DB in the form of a string with commas in between (4345,324,24,2424,64567,33...). This string could become quite large and contain 2-3 thousand numbers. It's stored in the DB and used quite frequently.

我在想,而不是从DB每个需要它的时候读它,它会更好,将其存储在会话它的加载后的第一次。

I'm thinking that instead of reading it from the DB every time it's needed, it'd be better to store it in the session after it's loaded the first time.

多少内存将1000 int的列表中选择所需?请问内存的大小还取决于自身,使得存储一个较大的INT(234332)花费的时间比小INT(544)?

How much memory would a list of 1,000 int require? Does the memory size also depend on the int itself such that storing a larger int (234,332) takes more space than a smaller int (544)?

难道会是更好的阅读一次,并在内存空间或更好的成本在会话存储经常阅读,并从内存丢弃渲染后。

Is it going to be better to read once and store in the session at the cost of memory space or better to read often and discard from memory after render.

感谢您的建议。

推荐答案

在C#中的int总是4个字节(无论什么值)。 1000整数列表因此〜4000字节。我说大约是因为表结构会增加一些开销。几千整数列表中的不应该是一个现代化的计算机有问题。

An int in C# is always 4 bytes (no matter what the value). A list of 1,000 ints is therefore ~4,000 bytes. I say approximately because the list structure will add some overhead. A few thousand ints in a list shouldn't be a problem for a modern computer.

这篇关于INT列表内存大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆