Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

348
Views
Kotlin Android Extensions vs Android Data Binding Library, memory usage

I have a question about memory used in both cases ->Android Data Binding vs Android Kotlin Extensions. In which case will be less memory used on the device?

Kotlin Android-extension is calling first findViewById and after that, the result will be stored locally in a cache. and this means memory used.

DataBinding creates a path between layouts and activities/fragments through the binding class that was created.

My concern is to use the one that is more efficient when we think of memory usage on the user's device. Could anyone help me to figure out the answer? I tend to say dataBinding is more efficient. Here is a similar question but is not in the efficiency direction.

Thanks!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

tldr: As far as I see it there is no difference depending memory usage, only if you don't use all views of the layout. Both cache the views, however andoid kotlin gets on demand while databinding initializes all. Depending performance, kotlin extensions is slightly(I would say in most cases not recognizable) faster than databinding during fragment/activity creation.

Documentation Kotlin Android Extensions:

Adds a hidden caching function and a field inside each Kotlin Activity. The method is pretty small so it doesn't increase the size of APK much. Replaces each synthetic property call with a function call.

How this works is that when invoking a synthetic property, where the receiver is a Kotlin Activity/Fragment class that is in module sources, the caching function is invoked. For instance, given

class MyActivity : Activity() fun MyActivity.a() { 
         this.textView.setText(“”) 
}

a hidden caching function is generated inside MyActivity, so we can use the caching mechanism.

However in the following case:

fun Activity.b() { 
    this.textView.setText(“”)
}

We wouldn't know if this function would be invoked on only Activities from our sources or on plain Java Activities also. As such, we don’t use caching there, even if MyActivity instance from the previous example is the receiver.

Reason: Kotlin uses synthetic properties and those are called on demand using caching function(Hence slight fast Activity/Fragment loading) while Databinding binds all views at once (that consumes slight more time).

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!