{"id":15722524,"url":"https://github.com/indiesoftby/defold-webgl-memory","last_synced_at":"2025-07-26T11:07:03.495Z","repository":{"id":194657409,"uuid":"691221731","full_name":"indiesoftby/defold-webgl-memory","owner":"indiesoftby","description":"A quick and easy way to find out the GPU and CPU memory usage of your Defold game on HTML5 platform.","archived":false,"fork":false,"pushed_at":"2025-05-06T08:34:51.000Z","size":6882,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-13T05:47:33.918Z","etag":null,"topics":["defold","defold-game-engine","defold-library","defold-module","defold-native-extension","html5-game-development"],"latest_commit_sha":null,"homepage":"https://indiesoftby.github.io/defold-webgl-memory/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/indiesoftby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-09-13T18:31:43.000Z","updated_at":"2025-04-09T10:26:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"4713c571-007c-46fd-b4b1-ced0891c61d8","html_url":"https://github.com/indiesoftby/defold-webgl-memory","commit_stats":null,"previous_names":["indiesoftby/defold-webgl-memory"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/indiesoftby/defold-webgl-memory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indiesoftby%2Fdefold-webgl-memory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indiesoftby%2Fdefold-webgl-memory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indiesoftby%2Fdefold-webgl-memory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indiesoftby%2Fdefold-webgl-memory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/indiesoftby","download_url":"https://codeload.github.com/indiesoftby/defold-webgl-memory/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indiesoftby%2Fdefold-webgl-memory/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267155791,"owners_count":24044396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["defold","defold-game-engine","defold-library","defold-module","defold-native-extension","html5-game-development"],"created_at":"2024-10-03T22:08:17.767Z","updated_at":"2025-07-26T11:07:03.464Z","avatar_url":"https://github.com/indiesoftby.png","language":"JavaScript","funding_links":[],"categories":["Libraries"],"sub_categories":["Programming Language"],"readme":"[![WebGL memory tracker cover](cover.jpg)](https://github.com/indiesoftby/defold-webgl-memory)\n\n# WebGL memory tracker for Defold\n\nA quick and easy way to find out the GPU and CPU memory usage of your Defold game on HTML5 platform.\n\nSo, this is an adaptation into a native extension of the excellent [WebGL-Memory](https://github.com/greggman/webgl-memory) library for the Defold engine. You add the extension to your project, then you can ask how much WebGL memory and resources you're using. It's important to keep in mind that WebGL-Memory tries to approximate the data, so the statistics may not be accurate.\n\nAs an extra bonus, this extension retrieves the size of the heap used by the game. \n\n\u003e [!IMPORTANT]\n\u003e Use the extension only during game development. **Remove it as a dependency** in the release version of the game! It wraps WebGL calls and therefore **slows down your game**.\n\nCheck out the [online demo](https://indiesoftby.github.io/defold-webgl-memory/) to see how it works.\n\n## Quick Start\n\nAdd this project as a [Defold library dependency](http://www.defold.com/manuals/libraries/). Open your `game.project` file and in the dependencies field under project add:\n\nhttps://github.com/indiesoftby/defold-webgl-memory/archive/main.zip\n\nRequest the data:\n\n```lua\nif webgl_memory then\n    local info = webgl_memory.get_info()\n    print(\"GPU memory used in total: \" .. math.floor(info.memory.total / 1024 / 1024) .. \" MB\")\n    print(\"CPU heap size: \" .. math.floor(info.memory.wasmheap / 1024 / 1024) .. \" MB\")\nend\n```\n\n## Usage\n\nWhen you call `webgl_memory.get_info()`, the result is:\n\n```lua\n{\n  context = {\n    vendor = \u003cstring\u003e,\n    renderer = \u003cstring\u003e,\n    unmasked_vendor = \u003cstring\u003e,\n    unmasked_renderer = \u003cstring\u003e,\n  },\n  memory = {\n    buffer = \u003cbytes used by buffers\u003e,\n    texture = \u003cbytes used by textures\u003e,\n    renderbuffer = \u003cbytes used by renderbuffers\u003e,\n    drawingbuffer = \u003cbytes used by the canvas\u003e,\n    total = \u003cbytes used in total\u003e,\n    wasmheap = \u003cbytes used by the Defold engine\u003e, -- is injected by the extension and equals to `Module.HEAP8.length`.\n  },\n  resources = {\n    buffer = \u003ccount of buffers\u003e,\n    renderbuffer = \u003ccount of renderbuffers\u003e,\n    program = \u003ccount of programs\u003e,\n    query = \u003ccount of query objects, WebGL2 only\u003e,\n    sampler = \u003ccount of samplers, WebGL2 only\u003e,\n    shader = \u003ccount of shaders\u003e,\n    sync = \u003ccount of sync objects, WebGL2 only\u003e,\n    texture = \u003ccount of textures\u003e,\n    transformFeedback = \u003ccount of transformfeedbacks, WebGL2 only\u003e,\n    vertexArray = \u003ccount of vertexArrays, only if used or WebGL2\u003e,\n  }\n}\n```\n\n### How to use this data\n\nIn HTML5 your main task is to minimise the memory consumption of the game. Firstly, modern mobile browsers [have OOM protection](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/android/oom_intervention/near_oom_reduction_message_delegate.cc;l=23?q=IDS_NEAR_OOM_REDUCTION_MESSAGE\u0026ss=chromium) and the browser can simply stop running your game and free up resources for other tasks if memory usage is too high. Secondly, allocating a large amount of memory for your game requires freeing up device resources, and this can lead to lags and slow startup of your HTML5 game.\n\n- **Minimise the required heap size.** Set the `game.project` heap size to 32 megabytes (minimum). Run the HTML5 build of your game and check the value of `webgl_memory.get_info().memory.wasmheap`. If it is greater than 32 megabytes, increase this parameter and run the game again.\n- **Use texture compression**: 16bpp or UASTC if their output image quality is OK to you. They will significantly reduce the size of the consumed video memory and speed up the performance of your game.\n- **Use 2k atlases** instead of 4k/8k atlases to reduce required heap size. Uncompressed RGBA 4k atlas with mipmaps uses 85x2 (190) megabytes of heap just to transfer it to the video adapter memory.\n\n## Credits\n\nThis project is licensed under the terms of the CC0 1.0 Universal license. It's developed and supported by [@aglitchman](https://github.com/aglitchman). \n\nIt includes includes a release version of WebGL-Memory, license MIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findiesoftby%2Fdefold-webgl-memory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Findiesoftby%2Fdefold-webgl-memory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findiesoftby%2Fdefold-webgl-memory/lists"}