Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ctypes infinite pointer cache #100926

Closed
Closed
Labels
@earonesty

Description

@earonesty

Bug(ish?) report

The following function has a cache. If you are using a factory to call ctypes.POINTER in a loop, the memory usage is unbounded and unable to be reclaimed.

https://docs.python.org/3/library/ctypes.html#ctypes.POINTER

The documentation should mention that this is unbounded and should not be called in a loop, or the cache should be changed to a configurable, bounded LRU cache.

Example of a variable length type factory used by windows, and a bad func that cannot be called in a loop:

def shitemid_factory(size: int) -> Type[ctypes.Structure]:    class SHITEMID_Var(ctypes.Structure):        _fields_ = (            ("cb", USHORT),            ("abID", BYTE * size),        )    return SHITEMID_Vardef bad_func():    SHITEMID_Var = shitemid_factory(sz - ctypes.sizeof(USHORT))    item_var = ctypes.cast(item_ptr, ctypes.POINTER(SHITEMID_Var))

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp