Giter VIP home page Giter VIP logo

little-lang's People

Contributors

traplol avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

moneytech

little-lang's Issues

A lot of memory ram usage (memory leaks, ...)

When I do a "stress testing" for a simple while-loop:

mut x = 10000000
while x > 0 {
    x = x - 1
}

It fills all RAM (can consume 2+ GB) for that loop. I has checked with valgrind tool (reducing x to 1000), and I got:

==2780== HEAP SUMMARY:
==2780==     in use at exit: 241,023 bytes in 8,519 blocks
==2780==   total heap usage: 8,679 allocs, 160 frees, 266,400 bytes allocated
==2780== 
==2780== 31 bytes in 1 blocks are definitely lost in loss record 280 of 506
==2780==    at 0x4C2AC3D: malloc (vg_replace_malloc.c:299)
==2780==    by 0x51C5839: strdup (strdup.c:42)
==2780==    by 0x40667B: LexerMake (lexer.c:355)
==2780==    by 0x406D54: LittleLangMachineMakeLexer (little_lang_machine.c:150)
==2780==    by 0x407546: LittleLangMachineInit (little_lang_machine.c:365)
==2780==    by 0x40687F: main (little_lang.c:10)
==2780== 
==2780== 32 bytes in 1 blocks are definitely lost in loss record 379 of 506
==2780==    at 0x4C2C9B4: calloc (vg_replace_malloc.c:711)
==2780==    by 0x40CB3E: ValueAllocNoGC (value.c:65)
==2780==    by 0x40D013: ValueMakeType (value.c:210)
==2780==    by 0x4022D6: GlobalsInitTypeInfos (globals.c:51)
==2780==    by 0x402965: GlobalsInit (globals.c:117)
==2780==    by 0x407624: LittleLangMachineRun (little_lang_machine.c:400)
==2780==    by 0x406899: main (little_lang.c:13)
==2780== 
==2780== 32 bytes in 1 blocks are definitely lost in loss record 380 of 506
==2780==    at 0x4C2C9B4: calloc (vg_replace_malloc.c:711)
==2780==    by 0x40CB3E: ValueAllocNoGC (value.c:65)
==2780==    by 0x40D013: ValueMakeType (value.c:210)
==2780==    by 0x402362: GlobalsInitTypeInfos (globals.c:52)
==2780==    by 0x402965: GlobalsInit (globals.c:117)
==2780==    by 0x407624: LittleLangMachineRun (little_lang_machine.c:400)
==2780==    by 0x406899: main (little_lang.c:13)

...

==2780== 120 (48 direct, 72 indirect) bytes in 1 blocks are definitely lost in loss record 487 of 506
==2780==    at 0x4C2AC3D: malloc (vg_replace_malloc.c:299)
==2780==    by 0x40B35F: SymbolAlloc (symbol_table.c:18)
==2780==    by 0x40B808: SymbolTableInsert (symbol_table.c:149)
==2780==    by 0x411E86: RegisterRuntime_core (runtime_core.c:81)
==2780==    by 0x411A58: RegisterRuntimes (registrar.c:18)
==2780==    by 0x404A87: InterpreterInit (interpreter.c:721)
==2780==    by 0x40763A: LittleLangMachineRun (little_lang_machine.c:404)
==2780==    by 0x406899: main (little_lang.c:13)
==2780== 
==2780== 878 (800 direct, 78 indirect) bytes in 20 blocks are definitely lost in loss record 498 of 506
==2780==    at 0x4C2AC3D: malloc (vg_replace_malloc.c:299)
==2780==    by 0x40631E: LexerGetNextToken (lexer.c:284)
==2780==    by 0x406416: LexerSharedGetNext (lexer.c:307)
==2780==    by 0x4067E7: LexerNextToken (lexer.c:388)
==2780==    by 0x40BE14: TokenStreamAddExistingTokens (token_stream.c:46)
==2780==    by 0x40BE8C: TokenStreamMake (token_stream.c:67)
==2780==    by 0x40B07D: Parse (parser.c:1319)
==2780==    by 0x407091: ParseProgramTrees (little_lang_machine.c:231)
==2780==    by 0x40732D: LittleLangMachineLoadModule (little_lang_machine.c:304)
==2780==    by 0x407662: LittleLangMachineRun (little_lang_machine.c:406)
==2780==    by 0x406899: main (little_lang.c:13)
==2780== 
==2780== LEAK SUMMARY:
==2780==    definitely lost: 1,663 bytes in 44 blocks
==2780==    indirectly lost: 301 bytes in 17 blocks
==2780==      possibly lost: 0 bytes in 0 blocks
==2780==    still reachable: 239,059 bytes in 8,458 blocks
==2780==         suppressed: 0 bytes in 0 blocks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.