You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?php$ffi = FFI::cdef("
enum{ //enum TestEnum{ //if enum has a name there is no memory leak TEST_ONE=0, TEST_TWO=1, };
");
echo$ffi->TEST_TWO; //echo 1 //the result is right but memory leak
i found the c ffi code when enum has no name make memory leak
Problem seems to be that for top-level anonymous type definition we never store the declaration anywhere else nor the type anywhere else. The declaration keeps owning the type and it goes out of scope. For anonymous fields this gets handled by the add_anonymous_field code that removes the type from the declaration. I think we should do something similar.
I tried this here, which seems to work, but it feels hacky: https://gist.github.com/nielsdos/62016be38fff00f97bfbee4a430cc009
Problem seems to be that for top-level anonymous type definition we never store the declaration anywhere else nor the type anywhere else. The declaration keeps owning the type and it goes out of scope. For anonymous fields this gets handled by the add_anonymous_field code that removes the type from the declaration. I think we should do something similar. I tried this here, which seems to work, but it feels hacky: https://gist.github.com/nielsdos/62016be38fff00f97bfbee4a430cc009
Description
The following code:
i found the c ffi code when enum has no name make memory leak
PHP Version
php 8.3
Operating System
windows,linux
The text was updated successfully, but these errors were encountered: