SShortSingh.
Back to feed

iOS dev eliminates memory crashes when exporting 1.2-gigapixel images using mmap

0
·1 views

A developer building Mozary, an iOS photo mosaic app, solved persistent out-of-memory crashes that occurred when exporting extremely large images on iPhone. The core problem was that a 1.2-gigapixel canvas requires roughly 4.8 GB of uncompressed RAM, far exceeding iOS memory limits that typically terminate apps well below that threshold. The fix involved backing the drawing canvas with a memory-mapped file using mmap, so pixel data pages out to disk instead of consuming RAM. A CGImage is then wrapped around the same memory mapping via CGDataProvider and streamed directly to a JPEG file, avoiding the costly makeImage() copy entirely. With this approach, RAM usage during export dropped from approximately 4.8 GB to a few dozen megabytes regardless of output size.

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 ·

Mastra Framework Lets TypeScript Developers Build AI Agents in ~60 Lines of Code

Mastra is a TypeScript-first framework for building production AI agents that reduces boilerplate code from roughly 400 lines to around 60 compared to raw SDK implementations. The open-source project has accumulated over 24,000 GitHub stars and reached 88 releases by May 2026, supporting more than 40 model providers through a single API. Unlike LangChain and LlamaIndex, which are primarily Python-based with lagging TypeScript ports, Mastra was built natively for TypeScript using familiar primitives like classes, Zod schemas, and async functions. Developers can scaffold a working project in minutes using a CLI wizard, then incrementally add custom tools, persistent memory, and an HTTP server. The framework wraps the Vercel AI SDK under the hood, allowing developers to drop down to lower-level control when specific behavior does not fit the framework's defaults.

0
ProgrammingDEV Community ·

How to Pick the Right Next.js Rendering Strategy for SEO and Performance

Next.js offers four rendering strategies — SSG, ISR, SSR, and CSR — each suited to different page types and SEO requirements. Static Site Generation (SSG) works best for stable content like blogs and portfolios, while Incremental Static Regeneration (ISR) suits frequently updated pages such as e-commerce listings. Server-Side Rendering (SSR) is ideal for personalized or dynamic public pages, whereas Client-Side Rendering (CSR) fits interactive dashboards and internal tools but offers the weakest SEO performance. Contrary to a common assumption, Next.js does not guarantee SEO benefits by default; the outcome depends on selecting the appropriate rendering method for each page. Developers are advised to mix strategies within a single project rather than applying one approach universally.

0
ProgrammingDEV Community ·

Developer Builds AutarkChat to Compare Multiple AI Models in One Workspace

A developer built AutarkChat after growing frustrated with manually copying prompts across multiple browser tabs to compare AI model outputs. The tool lets users send a single prompt to several models simultaneously, with each model streaming responses independently so a failure in one does not affect the others. AutarkChat supports custom OpenAI-compatible endpoints, enabling connections to providers such as OpenAI, DeepSeek, Mistral, Groq, and OpenRouter from a single interface. Each response displays token usage data inline, allowing users to evaluate cost, latency, and output quality side by side without consulting separate dashboards. The platform also supports reusable prompt contexts, reducing repetitive setup work during model evaluation sessions.

0
ProgrammingDEV Community ·

Student builds browser-based PDF editor from scratch after 14 months of development

A student developer spent 14 months building a new PDF engine entirely from scratch after finding that existing JavaScript libraries only supported creating or viewing PDFs, not editing them. The project began when the developer struggled to find a reliable web tool to edit a PDF and started investigating why true browser-based PDF editing was so rare. Building the engine required reading the official PDF specification and progressively implementing codecs, compression types, font support, and textbox recognition logic. Textbox grouping proved especially challenging since PDFs store text and coordinates but no structural grouping, requiring weeks of manual analysis across many documents. The finished product, available at KeyPDF.net, supports direct text editing, redaction, annotation, form filling, page organization, and metadata editing — all without a server.