SShortSingh.
Back to feed

Hand-Rolled LRU Caches Can Leak Memory When Sized by Entry Count

0
·1 views

A common LRU cache implementation limits capacity by number of entries, which ignores the real constraint of memory for items like decoded image thumbnails. The article recommends tracking a running byte budget and evicting from the least-recently-used end in a while loop, so a single large insert can free enough space. It also points out that using an ArrayDeque with remove(key) makes each access O(n), which can cause performance problems as the cache grows. The suggested fix pairs a hash map with a doubly linked list so that get and put run in constant time. The author notes these issues often surface only later as jank, so catching them early is the key skill.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Resolving tenant membership before running a Databricks SQL call

Requests that carry a tenant ID identify which tenant the caller wants, so access must be checked before any SQL is sent. The author walks through an open-source .NET 8 project, LakeWright.NET, whose example runs offline against a local loopback fixture with no workspace credentials. The sample allows a member to query their own tenant and denies access to another tenant without sending any statement. The resolver checks a trusted (tenant, principal) mapping, which should be replaced with a real membership lookup in production, and a parameterized statement is bound with a tenant context. The article also notes compatibility checks against .NET 8 and .NET 10 and points readers to troubleshooting steps.

0
ProgrammingDEV Community ·

Why EMI and EMC design matter for modern autonomous and industrial robots

An article in the STATERA Library's Volume 02 series examines electromagnetic interference (EMI) and electromagnetic compatibility (EMC) as critical engineering concerns for autonomous mobile robots, industrial robots, and related systems. It explains that dense electronics, high-power switching, and AI computing in compact robot bodies make electromagnetic noise a direct threat to reliability, safety, communication, and sensor accuracy. The piece distinguishes conducted from radiated emissions and susceptibility, then identifies motor drives, DC-DC converters, and high-speed GPU and Ethernet hardware as major noise sources. It also notes that communication buses like CAN and sensors such as GNSS, LiDAR, and radar are particularly vulnerable to interference.

0
ProgrammingDEV Community ·

IP Rating Explained: Protecting AMR Electronics from Dust and Water

This chapter of an AMR engineering series introduces IP (Ingress Protection) ratings, which standardize how well electrical enclosures shield equipment from contact, solid objects, dust, and water. It notes that autonomous mobile robots face contamination risks across batteries, controllers, sensors, and connectors in varied indoor and outdoor settings. The text explains that IP ratings define protection under controlled test conditions rather than overall durability, and cites IEC 60529 as the main international standard, with ISO 20653 covering automotive equipment. It describes the two-digit code, where the first digit addresses solid particles and access by hazardous parts and the second addresses water ingress. The discussion goes on to detail how these levels are tested and why a high dust rating does not guarantee equal water resistance.

0
ProgrammingDEV Community ·

AMR Wiring and Harness Design: Chapter 13 Contents Overview

This chapter of the AMR Mechanical and Electrical Engineering series, published by the STATERA Library, introduces wiring systems for autonomous mobile robots. It explains that wiring carries power, control commands, sensor signals, and communication data, and that its reliability underpins the whole robot's operation. The text argues that harness design is a core systems engineering discipline affecting reliability, maintainability, safety, and electromagnetic compatibility. It also outlines the table of contents, covering topics such as power and signal separation, high-current wiring, flexible cables, and inspection. The material is presented as a Korean-language reference document hosted on GitHub.