Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Intelligence View
⚡ tsecurity.de Intelligence

LazyColumn Performance Optimization — key, contentType & Recomposition Control

LazyColumn Performance Optimization — key, contentType & Recomposition Control Optimize LazyColumn rendering in Jetpack Compose. Master key parameter for diff updates, contentType for ViewHolder recycling, stability markers, lambda c…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!




LazyColumn Performance Optimization — key, contentType & Recomposition Control



Optimize LazyColumn rendering in Jetpack Compose. Master key parameter for diff updates, contentType for ViewHolder recycling, stability markers, lambda caching, and derivedStateOf for scroll-aware UI. Includes performance checklist.






1. The key Parameter — Why It Matters



Without explicit keys, Compose uses list indices. Indices change when items are added/removed, causing unnecessary recompositions and animation bugs.




// ❌ BAD: No keys — indices shift
LazyColumn {
items(items.size) { index ->
ItemCard(items[index])
}
}

// ✅ GOOD: Unique keys
LazyColumn {
items(
count = items.size,
key = { index -> items[index].id } // Stable, unique key
) { index ->
ItemCard(items[index])
}
}

// ✅ BETTER: Using extension
LazyColumn {
items(
items = items,
key = { it.id } // Each item has unique id
) { item ->
ItemCard(item)
}
}






Impact: Without keys, 100-item list deletion causes 99 unnecessary recompositions. With keys: only 1 recomposition (deletion).






2. contentType for Recycling



ViewHolder-like recycling: group items by type to reuse composition slots.




enum class ItemType { Header, Content, Footer, Ad }

data class ListItem(
val id: String,
val type: ItemType,
val title: String,
val body: String? = null
)

@Composable
fun OptimizedList(items: List<ListItem>) {
LazyColumn {
items(
items = items,
key = { it.id },
contentType = { it.type } // ← Recycling hint
) { item ->
when (item.type) {
ItemType.Header -> HeaderItem(item.title)
ItemType.Content -> ContentItem(item.title, item.body!!)
ItemType.Footer -> FooterItem(item.title)
ItemType.Ad -> AdBanner()
}
}
}
}






Benefit: Compose reuses composition slots for same type, reducing layout thrashing.






3. @stable & @Immutable Markers



Prevent unnecessary recompositions by marking immutable data classes.




@Immutable
data class User(
val id: String,
val name: String,
val avatar: String
)

@Stable
class UserViewModel {
private val _selectedUser = mutableStateOf<User?>(null)
val selectedUser: State<User?> = _selectedUser
}

// Without markers, Compose can't guarantee stability → extra recompositions
// With markers, Compose trusts data hasn't changed









4. Lambda Caching with remember



Callbacks passed to items should be memoized to prevent recompositions.




@Composable
fun UserListScreen(viewModel: UserViewModel) {
// ❌ BAD: New lambda every composition
LazyColumn {
items(viewModel.users) { user ->
UserCard(
user = user,
onDelete = { viewModel.deleteUser(user.id) } // ← New lambda each time
)
}
}

// ✅ GOOD: Memoized callback
val onDeleteCallback = remember {
{ userId: String -> viewModel.deleteUser(userId) }
}

LazyColumn {
items(viewModel.users) { user ->
UserCard(user = user, onDelete = { onDeleteCallback(user.id) })
}
}
}









5. derivedStateOf for Scroll-Aware UI



Detect scroll position changes without triggering full list recompositions.




@Composable
fun ScrollAwareList(items: List<String>) {
val lazyListState = rememberLazyListState()

// ✅ Derived state: only recomposes when result changes
val isScrolled by remember {
derivedStateOf {
lazyListState.firstVisibleItemIndex > 0 ||
lazyListState.firstVisibleItemScrollOffset > 0
}
}

Scaffold(
topBar = {
TopAppBar(
title = { Text("Scroll Aware") },
elevation = if (isScrolled) 4.dp else 0.dp // ← Conditional elevation
)
}
) { paddingValues ->
LazyColumn(
state = lazyListState,
modifier = Modifier.padding(paddingValues)
) {
items(items.size, key = { items[it].hashCode() }) { index ->
Text(items[index], modifier = Modifier.padding(16.dp))
}
}
}
}






Without derivedStateOf: Scroll → lazyListState change → full list recomposition.

With derivedStateOf: Scroll → derive Boolean → only TopAppBar recomposes.






6. Performance Checklist





















































Issue Solution Impact
No keys Add key = { it.id }
Huge: prevents index-shift recompositions
No contentType Add contentType = { it.type }
Medium: improves recycling
Mutable data Use @Immutable/@stable
Medium: helps compiler optimize
New lambdas Memoize with remember
Low-Medium: prevents child recompositions
Scroll state propagation Use derivedStateOf
High: isolates scroll logic
Large lists (>500 items) Add both keys + contentType Critical
Complex item UI Extract to separate @Composable Medium: enables skipping
State hoisted wrong Move state up correctly High: prevents recomposition leaks





7. Complete Example: Optimized User List






@Immutable
data class UserItem(val id: String, val name: String, val email: String)

@Composable
fun OptimizedUserList(
users: List<UserItem>,
onUserClick: (String) -> Unit
) {
val lazyListState = rememberLazyListState()
val isScrolled by remember {
derivedStateOf { lazyListState.firstVisibleItemIndex > 0 }
}

val handleClick = remember {
{ userId: String -> onUserClick(userId) }
}

Scaffold(
topBar = {
TopAppBar(
title = { Text("Users") },
elevation = if (isScrolled) 4.dp else 0.dp
)
}
) { paddingValues ->
LazyColumn(
state = lazyListState,
modifier = Modifier.padding(paddingValues)
) {
items(
items = users,
key = { it.id },
contentType = { "user" }
) { user ->
UserCard(
user = user,
onClick = { handleClick(user.id) }
)
}
}
}
}

@Composable
fun UserCard(user: UserItem, onClick: () -> Unit) {
Card(
modifier = Modifier
.fillMaxWidth()
.padding(8.dp)
.clickable(onClick = onClick)
) {
Column(modifier = Modifier.padding(16.dp)) {
Text(user.name, style = MaterialTheme.typography.bodyLarge)
Text(user.email, style = MaterialTheme.typography.bodySmall)
}
}
}









Summary



LazyColumn performance hinges on:





  1. key — Prevents index-shift recompositions (critical)


  2. contentType — Enables ViewHolder-like recycling


  3. @stable/@Immutable — Compiler optimization hints


  4. remember lambdas — Prevent callback churn


  5. derivedStateOf — Isolate scroll/selection state


  6. Extract composables — Enable skipping



For lists >500 items, use all techniques. For <50 items, keys + contentType suffice.






8 Android app templates: Gumroad

1. Sofort-Triage & Abwehrmaßnahmen

SOC Incident Playbook: Vulnerability Remediation & Verification
Syntax validiert (0 Fehler)
title: Detect Exploitation - LazyColumn Performance Optimization — key, contentType & Recomposition Control
id: bba74611-03a9-4d78-94aa-17ec853338f0
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-25
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
Syntax validiert (0 Fehler)
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-25"
        description = "YARA Signature for "
    strings:
        $str = "LazyColumn Performance Optimiz" ascii wide
    condition:
        any of them
}
Syntax validiert (0 Fehler)
index=security sourcetype IN ("cisco:asa", "pan:traffic", "zeek_conn", "suricata", "WinEventLog:Security")
("LazyColumn Performance Optimization  key")
| stats count earliest(_time) as first_seen latest(_time) as last_seen by src_ip, dest_ip, dest_host, signature
| eval first_seen=strftime(first_seen, "%Y-%m-%d %H:%M:%S"), last_seen=strftime(last_seen, "%Y-%m-%d %H:%M:%S")
| sort - count
Syntax validiert (0 Fehler)
message: "*LazyColumn Performance Optimization  key*"
Syntax validiert (0 Fehler)
CommonSecurityLog
| where Message has "LazyColumn Performance Optimization  key"
| summarize EventCount = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by SourceIP, DestinationIP, DestinationPort, Activity
| extend DetectionRule = "iShareStuff-CTI-Compiled"
| sort by EventCount desc

2. Cyber Threat Intelligence & Forensik

🎯
MITRE ATT&CK Matrix Navigator 14 Taktiken
Reconnaissance
-
Resource Development
-
Initial Access
Execution
Persistence
-
Privilege Escalation
Defense Evasion
Credential Access
-
Discovery
-
Lateral Movement
-
Collection
-
Command and Control
Exfiltration
-
Impact
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich LazyColumn Performance Optimization — ke.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten LazyColumn Performance Optimization — key, contentType & Recomposition Control

Thematisch verwandte Begriffe: LazyColumn, Performance, Optimization, contentType · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-97818 | phpIPAM through 1.8.3 has incorrect authorization for id=="admins" and i…
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag