Currently GLib.Value is a value type (aka struct). This means that it can't have a finalizer and also that it can be simply copied around without any additional operations happening.
All that is fine if the value contains integers or similar things but falls apart if it contains pointers to something else (strings, objects, boxed types, ...). Then it will
- cause memory leaks (a manual
Dispose() call will fix that but the GC would never do that automatically)
- memory corruptions (value types can be copied around and then we have two
GLib.Values with the same pointer...)
Value types should never be used for anything that handles native resources for the above reasons.
Unfortunately changing it to a reference type (aka class) is not so easy due to how it is used everywhere right now.
Currently
GLib.Valueis a value type (aka struct). This means that it can't have a finalizer and also that it can be simply copied around without any additional operations happening.All that is fine if the value contains integers or similar things but falls apart if it contains pointers to something else (strings, objects, boxed types, ...). Then it will
Dispose()call will fix that but the GC would never do that automatically)GLib.Values with the same pointer...)Value types should never be used for anything that handles native resources for the above reasons.
Unfortunately changing it to a reference type (aka class) is not so easy due to how it is used everywhere right now.