0

How are objects in heap represented in Dalvik VM and JVM, respectively, in terms of the object size and field order. Are they the same (like mirror)?

Is it possible to migrate the heap objects in DVM to JVM? For example, for each object in DVM heap, allocate an object of the same type in JVM, and then copy the content byte by byte (or, field by field).

trincot
  • 317,000
  • 35
  • 244
  • 286
Infinite
  • 3,198
  • 4
  • 27
  • 36
  • It is *not* possible to migrate them *without* losing whatever differences there may be. For example, Object Serialization will serialize them in a standard format defined in the Protocol appendix of the Object Serialization Specification. XML and JSON serialization use an intermediate text format which is also standardized. Your question is without point. – user207421 May 10 '16 at 01:56
  • @EJP Thanks. But by dumping the heap and converting it to a standard .hprof file, the heap objects indeed can be understood by standard JVM memory analyzer. For example, [link](https://www.novoda.com/blog/debugging-memory-leaks-on-android-for-beginners-programmatic-heap-dumping-part-1/) So I think it might be doable. – Infinite May 10 '16 at 02:32
  • Possibly of interest: http://stackoverflow.com/questions/10824677/is-dalvik-even-more-memory-hungry-than-hotspot-in-terms-of-object-sizes/ – fadden May 10 '16 at 19:20

1 Answers1

0

No. The in-memory representation will be totally different than that of other VMs. The in-memory representation will vary by version of Android, whether it's running art or dalvik, and potentially even be different for different devices running the same version of Android.

Anything you try to do at that level is extremely brittle, and would likely only work on a single device, or small set of devices.

JesusFreke
  • 19,784
  • 5
  • 65
  • 68