It's an Android serialization question! Android Serializable

Asked 2 years ago, Updated 2 years ago, 120 views

Hello, while studying Android, I have a question, so I posted this question.

I suddenly remembered watching YouTube, where the serialization of objects that I saw once said that data transfer was very bad for performance, so I just watched it again.

https://www.youtube.com/watch?v=IwxIIUypnTE&annotation_id=annotation_588829075&feature=iv&src_vid=qBxeHkvJoOQ

I watched this video.

In this video, serialization is not good for performance, so I recommend you to use something else Gson, parallel, shared preference, and so on.

What I'm curious about here is

I'm just using serializable for the app I'm making for practice, but I'm going to use it to practice and study!

android performance

2022-09-22 21:43

1 Answers

If you want to send and receive objects between activities with Intent, if you can modify the object (class) to implement a parallel interface, you'd better do it this way, and if not, think about another way in the next lane.

Even with a few String data, the mechanism of action that Serializable has can be a significant burden on memory. I don't know how Android Java handles it, but when it's usually declared serializable, Java tries to place the members of that object in consecutive memory spaces. The larger the junk (object), the more problems with memory management in the JVM.

Reference

Serializable is an interface created in Java to allow objects in memory to pass to other systems (Java machines) via network, file-like I/O, except for the description of the actual mechanism of operation. In general, if you simply inherit the serializable interface, the serialization process is handled by the JVM itself, but the conversion cost is quite high.

Parcelable can be considered as a substitute for Serializable when exchanging objects between android Java on Android.


2022-09-22 21:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.