1

In C++ it could do something like obj.sizeOf() to check the object's size in memory.

How to do it with kotlin in Android? Need to check how much an object is consuming the memory.

(can't use java.lang.instrumentation with Android)

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
lannyf
  • 9,865
  • 12
  • 70
  • 152
  • 1
    `sizeOf` is a complie time constant it won't tell you a lot. You can achieve the same by counting the number of feilds contained in an object. – al3c Aug 13 '20 at 17:20
  • (For reference, this is a variation on [these](https://stackoverflow.com/questions/52353/in-java-what-is-the-best-way-to-determine-the-size-of-an-object) [questions](https://stackoverflow.com/questions/9368764/calculate-size-of-object-in-java), but none of their answers seem to apply to Android.) – gidds Aug 13 '20 at 18:01

0 Answers0