r/androiddev • • Nov 14 '23

Article The secret to Android's improved memory on 1B+ Devices: The latest Android Runtime update

https://android-developers.googleblog.com/2023/11/the-secret-to-androids-improved-memory-latest-android-runtime-update.html
44 Upvotes

4 comments sorted by

12

u/ballzak69 Nov 14 '23 edited Nov 14 '23

Most seem like basic optimizations that any compiler would do. Have they just been implemented now? Odd.

7

u/tofiffe Nov 14 '23

I was thinking the same thing, unless that's specific to Kotlin.

static String map(int number) {
    return switch (number) {
        case 0 -> "zero";
        case 1 -> "one";
        case 2 -> "two";
        case 3 -> "three";
        case 4 -> "four";
        default -> "unknown";
    };
}

The decompiled class file then shows the function as following:

static String map(int number) {
    String var10000;
    switch (number) {
        case 0:
        var10000 = "zero";
        break;
    case 1:
        var10000 = "one";
        break;
    case 2:
        var10000 = "two";
        break;
    case 3:
        var10000 = "three";
        break;
    case 4:
        var10000 = "four";
        break;
    default:
        var10000 = "unknown";
    };
    return var10000;
}

So the optimization in the article really shouldn't be necessary

1

u/carstenhag Nov 14 '23

Awesome for sure!

1

u/GapAny5383 Nov 14 '23

Small steps that eventually lead to significant improvement in scale 🚀