Похожие чаты

For example, how much?

3 ответов

13 просмотров

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.

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

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

Ну вот просто даже давайте вот как. Какой нибудь конкретный кейс, можете в пример привести, где бч работает и приносит прикладную пользу, а не просто что бы было? Не крипту.
Alexander Andreev
22
Всем привет! Имеется функция: function IsValidChar(ch: UTF8Char): Boolean; var i: Integer; ValidChars: AnsiString; begin ValidChars := 'abcdefghijklmnopqrstuvwxyzABCDE...
Евгений
44
For all those that keep asking why no pump? why this ? and why that...? Please close ur ewt chart and open 2 others - TOTAL (total mc) and BTC.D (btc dominance). Maybe BTC a...
Inn3r_G
19
"Since pnut can flip FTM easily, I'm swapping my FTM to pnut and hoping for a easy x5-x10" Perfect recipe for disaster. NFA but chances are, you'll end up as exit liquidity ...
C. A.
7
объясните пожалуйста, почему функция не работает должным образом? вроде должно брать активное окно сравнивать его размер с размером экрана, и если есть совпадение = true прове...
JF
9
AMD status update? No longer in the plan but something might be around the corner later on Chinese partner? No longer in the plan. This market does not seem to be the top ...
Ben
6
Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
255
да кстати заметил всюда почему то всех сюда прёт, ни в одном чате столько ботов не прёт как сюда.. Может чота надо доработать?
REDis
15
I get confused when people talk about the ‘bull market’ and the ‘next bull market’ as if anyone really has a clue what’s really going on in the world. First of all - there i...
Shah
1
Мне вот любопытно. Уже сколько времени имею соблазн купить макбук, ибо подозреваю что очень уж удобен будет в связке с другой техникой от эпл которая у меня есть, да и сам по ...
Not Yeromin
14
Карта сайта