There is one problem in the project that can be solved in two ways. But I can not estimate which way will be "cheaper" for memory.

How to correctly calculate on an Android device, how much do certain objects weigh in java?

PS In one case, it is an array of List from other objects, which in turn contain other objects, in the other it is a subscriber from Rx.

PS2: Perhaps there are some other ways to assess the speed of performance or occupied by objects of memory, in addition to the trivial calculation of differences in time / memory spent before and after in both cases?

  • 1. calculate each data type. 2. use Java-agent to view objects in memory and their size. - Senior Pomidor
  • @pavlofff judging by the link is what you need! Thank you very much. Please, register as an answer to close my question! - abbath0767

1 answer 1

Android Studio includes a number of tools for profiling the application. They will help evaluate the memory allocated to the application and its objects, the contents of the heap, the performance, the load on the device, etc. during program execution.

You need to profile both options and compare the results.