{"id":26272297,"url":"https://github.com/layer26/unmanaged-memory","last_synced_at":"2025-09-06T01:48:55.986Z","repository":{"id":117422102,"uuid":"125010768","full_name":"layer26/Unmanaged-Memory","owner":"layer26","description":"Provide unmanaged memory allocation, memory heap creation.","archived":false,"fork":false,"pushed_at":"2018-10-27T19:27:44.000Z","size":33,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-23T02:03:22.551Z","etag":null,"topics":["csharp","heap-allocation","memory-allocation","memory-management","winapi"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/layer26.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2018-03-13T07:34:24.000Z","updated_at":"2022-03-02T12:29:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"169b11de-0f7e-4b61-abe9-547bf24b2df0","html_url":"https://github.com/layer26/Unmanaged-Memory","commit_stats":null,"previous_names":["layer26/unmanaged-memory"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/layer26/Unmanaged-Memory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/layer26%2FUnmanaged-Memory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/layer26%2FUnmanaged-Memory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/layer26%2FUnmanaged-Memory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/layer26%2FUnmanaged-Memory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/layer26","download_url":"https://codeload.github.com/layer26/Unmanaged-Memory/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/layer26%2FUnmanaged-Memory/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273847181,"owners_count":25178641,"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-09-05T02:00:09.113Z","response_time":402,"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":["csharp","heap-allocation","memory-allocation","memory-management","winapi"],"created_at":"2025-03-14T07:24:43.359Z","updated_at":"2025-09-06T01:48:55.963Z","avatar_url":"https://github.com/layer26.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unmanaged Memory\nThis library provides memory that can not be collected by the CLR gc and Memory heap allocation.\n\n**You should think twice when you need like this functions. Unmanaged Memory Allocation is isn't REALLY good idea in GC Environment. I recommend use this code only for study.** [If you need reason, Reference this stackoverflow question.](https://stackoverflow.com/questions/49296960/heapalloc-heapcreate-is-garbage-collectable-in-c-sharp)\n\n\nMemory areas allocated using this library are not collected by gc and must be released by the programmer. **A memory leak occurs when all references are disconnected without being released.**\n\n\nThis library also uses WinAPI. **It doesn't work on non-Windows platforms.**\n\n\nFor the WinAPI used in this library, please refer to the \"List of Used WinAPIs\" below.\n\n# Examples\n```\n/// Allocation Unmanaged memory\nMemory memroy = Memory.Allocation(4); // 4Bytes Memory allocation.\n```\n\n```\n/// Access Memory\nbyte data = memory[0];\nmemory[0] = 2;\n\nbyte[] datas = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF};\nmemory.WriteBytes(datas, 0, datas.Length);\n```\n\n```\n/// Release Memory\nmemory.Free();\n```\n\n```\n/// Since VS2017, C++ Version Memory release\ndelete memory; // memory : Address (in C#, IntPtr type variable.)\n```\n\n```\n/// Dispose Free\nusing (Memory memory = Memory.Allocation(4))\n{\n  memory.IsFreeOnDispose = true; // This code will be make automatic memory release.\n  ...\n}\n```\n\n```\n/// Allocation Memory heap and Use.\nHeap memoryHeap = Heap.CreateHeap();\nMemory memory = Memory.Allocation(memoryHeap, 8); // 8Bytes Memory allocation on \"memoryHeap\" Heap.\n```\n\n```\n/// Destory Memory heap\nmemoryHeap.Destory();\n```\n\n# List of Used WinAPIs\n   ## List of Data types\n  - HeapFlags : A 32-bit unsigned integer, Bit Flags.\n  - IntPtr : Variable. (x32, 4Byte / x64, 8Byte)\n  \n   ## IntPtr GetProcessHeap()\n  - Dll : Kernel32.dll\n  - Symbol : GetProcessHeap\n  - MSDN Link : https://msdn.microsoft.com/en-us/library/windows/desktop/aa366569(v=vs.85).aspx\n  \n   ## uint GetProcessHeaps(uint, IntPtr[])\n  - Dll : Kernel32.dll\n  - Symbol : GetProcessHeaps\n  - MSDN Link : https://msdn.microsoft.com/en-us/library/windows/desktop/aa366571(v=vs.85).aspx\n  \n   ## IntPtr HeapAlloc(IntPtr, HeapFlags, uint)\n  - Dll : Kernel32.dll\n  - Symbol : HeapAlloc\n  - MSDN Link : https://msdn.microsoft.com/en-us/library/windows/desktop/aa366597(v=vs.85).aspx\n    \n   ## IntPtr HeapFree(IntPtr, HeapFlags, IntPtr);\n  - Dll : Kernel32.dll\n  - Symbol : HeapFree\n  - MSDN Link : https://msdn.microsoft.com/en-us/library/windows/desktop/aa366701(v=vs.85).aspx\n\n   ## IntPtr CopyMemory(IntPtr, IntPtr, uint)\n  - Dll : Kernel32.dll\n  - Symbol : CopyMemory\n  - MSDN Link : https://msdn.microsoft.com/ko-kr/library/windows/desktop/aa366535(v=vs.85).aspx\n\n   ## IntPtr CreateHeap(HeapFlags, uint, uint)\n  - Dll : Kernel32.dll\n  - Symbol : CreateHeap\n  - MSDN Link : https://msdn.microsoft.com/ko-kr/library/windows/desktop/aa366599(v=vs.85).aspx\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flayer26%2Funmanaged-memory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flayer26%2Funmanaged-memory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flayer26%2Funmanaged-memory/lists"}