Похожие чаты

For example, how much?

3 ответов

7 просмотров

Do memory footprint yourself u will understand

http://java-performance.info/overview-of-memory-saving-techniques-java/

Each object instance holds a pointer to it's class object, this is exactly the extra memory for each wrapper object. I guess, it's system dependent, and it would be 8 bytes on 64 bit machine. It means that each "Integer" object, for example, takes 4b+8b=12b of memory in heap while of primitive "integer" that takes 4b on stack or in heap (this difference is mostly irrelevant in java in terms of performance). For booleans, if they are represented as 1b what is usually the case, it's 1b+8b=9b that is 9 times more memory. However, for booleans usually there's no need to create new instance, just use Boolean.TRUE or Boolean.FALSE. Same happens for some set of other primitive common values (like 0-256): if they can be determined at compile time compiler uses statically defined value. Autoboxing works the same way, if I remember correctly. As you see using objects has significant impact on memory it takes. But in most cases it doesn't really matter much. Just check heap dump of your application and calculate how much would grow memory footprint if you were using wrapper classes. I bet not much. Unless you're developing for embedded device you just shouldn't care too much. Even for most cases in android development. However, you should consider this extra memory footprint if you develop something that is very restrictive in memory or very number manipulation extensive.

Похожие вопросы

Обсуждают сегодня

Ясн. Но я всеравно к кедам отношусь с опасением. Чисто субьективное кедосозерцание. Что касаемо "восторга изяшности кед" так и не вкурил, хотя много слышал, пока не поставил с...
Артем Записной
30
Такой вопросец - есть функция function MySuperDuperConcat(const a: array of AnsiString): AnsiString; Как мне в её теле сделать вот так? Result:=Concat(a); А не грустный вариан...
notme
15
Есть какой-нибудь для Delphi/FPC T*Compression(Decompression)Stream на базе LZ4/Zstd/любой другой быстрый(и хорошо сжимающий) алгоритм А ещё лучше в pure pascal А ещё лучше од...
notme
48
type TObj = object procedure Init; virtual; end; TObj1 = object(TObj) procedure Init; override; end; procedure TObj1.Init; begin inherited; end; procedur...
Alexander 👋
29
They keep hyping $FUN but where's the progress? 🙄
Noah Noure
23
Btw guys very stupid question but i haven't researchd so js asking you pros . Can ltc be traced too? Literally point to pint to the user? And getting the banks blocked ? Exch...
20
А чем вам питонисты не угодили?😂
.
79
Hey guys, did you see the new announcement about $Fun? 🔥
Filip Murphy
55
How can a minority hashrate chain defend from a fork-hopping ASIC miner? The problem: 1. A miner comes into your network, and mines at 60-70% hashrate. 2. After some time, th...
Kishniev
13
yeap, thanks guys for response, but I really like to understand does a pool created on curve.fi has the option or api or I can call a function of a smart contract to set excha...
Oleg Karoza
11
Карта сайта