Comments (6)
You should consider FromIntPtr an "weak reference" do not dispose it.
from keralua.
In this case the returned object should not be marked as disposable. I mean, if an object is disposable then it should be disposed. Since we call a method that returns a disposable object, we are expected to dispose it properly, that's what IDisposable is made for. And it is not obvious that we should not dispose it in such a case. Leaving dangling disposable objects without properly cleaning the resources is a bad practice, I think.
from keralua.
an type that is disposable don't me it SHOULD be disposed, it means it CAN be disposed. Is common practice to to have disposed objects being returned in APIs
For instance in Xamarin.iOS https://learn.microsoft.com/en-us/dotnet/api/uikit.uiview.viewwithtag?view=xamarin-ios-sdk-12 ViewWithTag
will return an UIView
that is Disposable.
The .NET docs say, you should disposed when you finish using it.
from keralua.
I beg your pardon here for interjecting, but then why is it IDisposable
?
I've been thinking the same as the OP, but I also see your explanation that there's no must in that it must be disposed.
Then my question is:
What are the situations when it can be disposed? What is the intended usage pattern when I might have actually disposed it?
from keralua.
It's disposable because the Lua object is disposable. For instance Console.Out
return a disposable TextWriter
but that doesn't mean you MUST dispose it.
from keralua.
Ah alright, so in this case we're getting the Lua object directly, not just a reference to it.
Then yeah, I guess we shouldn't dispose it.
To answer my own question, as I understand it: we can dispose it if we really want to dispose the Lua VM at this point.
from keralua.
Related Issues (20)
- Xamarin/Android: dlopen liblua53.so fails HOT 12
- Logo Copyright HOT 1
- Can't Build using VS 2019 Native Tools HOT 5
- 当lua代码出现死循环 我该怎么停止运行 这个时候button没有反应
- Fails to load lua53 assembly when building with Mono. HOT 9
- when reference by a classlib and build with any cpu (vs 2019) HOT 9
- State.NewLib State.SetFuncs: Attempted to read or write protected memory HOT 1
- Docs / Examples HOT 2
- How to use KeraLua.Lua.NewUserData correctly HOT 2
- Where is cyrillic support? HOT 6
- LuaSocket Debugger Support
- Build fails in Ubuntu/WSL using latest git HOT 1
- Linux library is not portable across distributions HOT 1
- Is it thread clean , when use as one tread one lua VM
- Can you open only some libraries? HOT 5
- Why data can be written at an offset memory location? HOT 1
- Can The State Be Set?
- DllNotFoundException with Unity
- NLua.Exceptions.LuaScriptException:“[string "chunk"]:3: attempt to index a nil value (global 'bit')” HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keralua.