Skip to content

Latest commit

 

History

History
48 lines (31 loc) · 869 Bytes

File metadata and controls

48 lines (31 loc) · 869 Bytes

Memory Management in TechLang

TechLang manages memory automatically, but also provides commands for advanced control and inspection.

Automatic Memory Management

Most objects are managed automatically. Unused memory is reclaimed by the garbage collector.

Manual Resource Management

For resources like files or sockets, always close them when done:

let f = open("file.txt")
... // use the file
f.close()

Inspecting Memory Usage

Check current memory usage:

let mem = memory_usage()
print("Memory used:", mem, "bytes")

Freeing Unused Memory

Request a manual garbage collection (optional):

gc_collect()

Working with Large Data

When handling large datasets, process data in chunks to reduce memory usage:

for line in readlines("largefile.txt") {
    process(line)
}

See the