嵌入:mono 与 lua

发布于 2024-07-14 01:21:32 字数 417 浏览 5 评论 0原文

我有兴趣了解人们在 C/C++ 应用程序中嵌入 mono(.NET 的开源实现)的经验。 如何分发这样的应用程序以及依赖项是什么? 我已经在 OS X 上进行了测试,mono 是一个巨大的框架(数百 MB)。 我的应用程序的用户都需要这个大框架吗?或者可以将其剥离或将所有内容编译到主可执行文件中。

我以前有过在 C++ 应用程序中嵌入 Lua 的经验,效果非常好,因为我可以将整个 lua 解释器静态链接到我的主可执行文件中。 所以我没有外部依赖。 是否可以用 mono 做类似的事情?

这里有 Lua 人可以评论一下他们如何发现 Mono 与 Lua 相比吗?

PS:我所说的嵌入是指一个 C++ 应用程序,它初始化一个单环境并加载 .NET 程序集并执行它,然后允许程序集中的 C# 代码与主可执行文件中的 C++ 方法之间进行通信。

I am interested in hearing about peoples experience with embedding mono (open source implementation of .NET) in a C/C++ application. How is it to distribute such an application and what are the dependencies? I have tested on OS X and mono comes as a huge framework (hundreds of MB). Do users of my app all need this big framework or can it be stripped down or everything be compiled into the main executable.

I previously have experience with embedding Lua in a C++ app, and that works really well because I can link statically the whole lua interpreter in with my main executable. So I have no external dependencies. Is it possible to do something similar with mono?

Any Lua people here who can comment on how they found mono compared to Lua?

PS: By embedding I mean a C++ application which initializes a mono environment and loads a .NET assembly and executes it and then allows for communication between say C# code in assembly and C++ methods in main executable.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

琉璃梦幻 2024-07-21 01:21:32

您可能还应该看看 Mono 的 Small Footprint 页面,该页面描述了如何嵌入更小的运行时。 哎呀,他们自己用 Moonlight 来做这件事。

我希望这有帮助。

You should probably also take a look at Mono's Small Footprint page that describes how you can embed a smaller runtime. Heck, they do it themselves with Moonlight.

I hope that helps.

夏天碎花小短裙 2024-07-21 01:21:32

这是2年前的问题了。 所以现在情况可能会有所不同。

对我来说,最重要的一点是 GC。 我为交互式应用程序和游戏嵌入了 Lua,因为需要增量 GC。 目前Lua 5.1有精确的增量GC,但我在Mono上找不到任何增量或精确GC的证据。 因此内存会泄漏(即使它非常小!),并且应用程序会间歇性地陷入困境。

人们说 GC 暂停可以通过调整一些参数和池化对象来解决,但根据我的经验,如果没有任何类型的 GC 中的随着时间的推移分配 GC 负载方法,就永远无法解决 GC 暂停问题。 分代GC是一种分布算法,但它太粗糙,几乎没有帮助。

因为您无法通过池化非您代码中使用的对象来控制生命周期模式或重用实例。 (例如基本类库)

因此我不推荐将 C# 平台(至少目前是 Mono 或 .NET)用于交互式/(软)实时应用程序。


编辑

我不知道Mono 或.NET 上是否存在任何增量/并发接近的GC。 如果你能确定他们提供了那种GC,当然,使用就可以了:)

This is 2 years old question. So situation may become different now.

For me, most important point was GC. I embedded Lua for interactive-apps and games, because incremental GC required. Currently Lua 5.1 has precise, incremental GC, but I couldn't found any proof of incremental or precise GC on Mono. So memory will leak (even it's very tiny!), and apps will struggle intermittently.

People says GC pause can be solved by tuning some parameters and pooling objects, but as I experienced, It never be solved without any kind of distribution GC load over time approach in GC. Generational GC is one of distribution algorithm, but it's too rough, and almost not helpful.

Because you can't control lifetime pattern or reuse instance by pooling the objects used in code that not yours. (such as basic class library)

So I don't recommend the C# platform (Mono or .NET, at least yet) for interactive/(soft)realtime apps.


Edit

I don't know whether any incremental/concurrent approached GC is presented on Mono or .NET. If you can sure about they offer the kind of GC, of course, it's fine to use :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文