How do I get the amount of physical memory, consumed by the DataSource (specifically — ByteArrayDataSource)? I use javax.mail.util.ByteArrayDataSource (byte[] bytes, String type) constructor, where I get bytes like this:
String str = "test";
byte[] bytes = str.getBytes();
Would that be str.length() in bytes? Any other ideas?
str.length() will give the number of characters
bytes.length will give the actual number of bytes.
Depending on your active character set this may or may not be the same. Some characters are encoded as multiple bytes.
example :
returns
4
4
1
4