0Pricing
WebAssembly (WASM) for High Performance Apps · Ders

Doğrusal Belleği Büyütme ve Yönetme

WASM doğrusal belleğinin isteğe bağlı olarak nasıl büyüdüğünü, nasıl boyutlandırılacağını ve JavaScript ile modülden ayırmanın nasıl güvenle yönetileceğini öğrenin.

Doğrusal Belleği Büyütme ve Yönetme, CoddyKit'te ücretsiz bir WebAssembly (WASM) for High Performance Apps dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, WebAssembly (WASM) for High Performance Apps öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. WebAssembly (WASM) for High Performance Apps kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

One Big Array

WASM stores all its data in a single, contiguous block called linear memory, exposed to JS as a growable ArrayBuffer.

Understanding how it grows and how to manage it is key to high-performance modules.

Memory Is Page-Based

Linear memory is measured in pages of 64 KiB each.

  • 1 page = 65536 bytes
  • Memory grows in whole pages, never partial

Declaring Initial and Max Size

When creating memory you set an initial and optional maximum number of pages.

const memory = new WebAssembly.Memory({
  initial: 2,   // 128 KiB
  maximum: 100  // up to ~6.4 MiB
});

Growing Memory

Call grow(n) to add n pages. It returns the previous size, or throws if it would exceed the maximum.

const prevPages = memory.grow(1); // add one 64 KiB page

Buffers Become Detached

Important: growing memory detaches the old ArrayBuffer. Any typed-array view you held is now invalid, re-create it after growth.

memory.grow(1);
// old view is stale; make a fresh one
const view = new Uint8Array(memory.buffer);

Growing From Inside WASM

WASM code grows its own memory with the memory.grow instruction; allocators like Rust's do this automatically when the heap fills.

(memory.grow (i32.const 1)) ;; grow by 1 page

Allocators on Top of Memory

Languages provide an allocator (malloc, Rust's global allocator) that carves the linear memory into objects.

You rarely manage raw offsets, you let the allocator and bindings do it.

Allocating From JS

Emscripten exposes _malloc and _free so JS can reserve space in WASM memory for data to pass in.

const ptr = Module._malloc(1024);
// ... use the buffer at ptr ...
Module._free(ptr);

Avoiding Leaks

Memory you allocate must be freed, WASM has no garbage collector for its linear memory. Forgetting free leaks until the module is discarded.

Sizing Strategy

Tune memory for your workload:

  • Start with enough initial pages to avoid early growth
  • Set a maximum to cap runaway usage
  • Remember each grow detaches views, batch growth when possible

Best Practices Summary

To manage linear memory well:

  • Think in 64 KiB pages
  • Re-create views after every grow
  • Pair every alloc with a free
  • Pick sensible initial and maximum sizes

Quick Check

What must you do immediately after calling memory.grow()?

Recap

You learned to manage WASM linear memory:

  • Memory grows in 64 KiB pages via grow()
  • Growth detaches buffers, refresh your views
  • Allocators and _malloc/_free carve the space
  • Free what you allocate; size initial/max thoughtfully

Careful memory management keeps high-performance WASM apps fast and leak-free.

Sıkça Sorulan Sorular

“Doğrusal Belleği Büyütme ve Yönetme” dersi ücretsiz mi?

Evet — “Doğrusal Belleği Büyütme ve Yönetme” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve WebAssembly (WASM) for High Performance Apps kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. WebAssembly (WASM) for High Performance Apps kursu toplamda 4 dersten oluşur.

“Doğrusal Belleği Büyütme ve Yönetme” dersinde ne öğreneceğim?

WASM doğrusal belleğinin isteğe bağlı olarak nasıl büyüdüğünü, nasıl boyutlandırılacağını ve JavaScript ile modülden ayırmanın nasıl güvenle yönetileceğini öğrenin. WebAssembly (WASM) for High Performance Apps ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

WebAssembly (WASM) for High Performance Apps öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te WebAssembly (WASM) for High Performance Apps, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.

“Doğrusal Belleği Büyütme ve Yönetme” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu WebAssembly (WASM) for High Performance Apps dersinde kod yazıp çalıştırabilir miyim?

Evet. Her WebAssembly (WASM) for High Performance Apps dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Karmaşık Veri Yapılarını Aktarma
  2. WASM Bellek Modeli ve Yönetimi
  3. Paylaşılan Bellek ve Atomikler
  4. Doğrusal Belleği Büyütme ve Yönetme
← WebAssembly (WASM) for High Performance Apps Sayfasına Dön