drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
MIT License
11.04k stars 1.06k forks source link

d: library not found for -lmimalloc-static #1994

Closed AmdRyZen closed 2 months ago

AmdRyZen commented 2 months ago

我 drogon_ctl create project test-drogon 创建了一个新项目 报以下异常 是因为新的版本 drogon 必须绑定 mimalloc 吗 ld: library not found for -lmimalloc-static collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed.

an-tao commented 2 months ago

不必须,它找到了才会连

AmdRyZen commented 2 months ago

我现在安装了mimalloc mimalloc-static 报错 mimalloc 就正常 是不是 存在内存泄漏

image image
an-tao commented 2 months ago

看看调用堆栈,在哪里报的

AmdRyZen commented 2 months ago
image

看起来像 main里面 的

image
AmdRyZen commented 2 months ago
image

果然成功了
mimalloc-static 认为这个有内存泄漏

AmdRyZen commented 2 months ago
image

要么这样也行

an-tao commented 2 months ago

把环境、编译器和复现步骤告知下,我试试,谢谢

AmdRyZen commented 2 months ago

系统 macos
CPU Apple M2 Pro
编译器 gcc 11.4.0 内存分配器 find_package(mimalloc 2.1.2 REQUIRED)
动态链接 mimalloc 正常 前提条件 drogon::app().addListener("0.0.0.0", 5555); 静态链接 mimalloc-static 异常 前提条件 drogon::app().loadConfigFile("config.json").run();

AmdRyZen commented 2 months ago
image image

我从这里看的 最新一期怎么跑不过test了

an-tao commented 2 months ago

好像docker环境问题,最近好久没关注tfb了

AmdRyZen commented 2 months ago

👌🏻 上面那个问题 好了 通知我

an-tao commented 2 months ago

MacOS上mimalloc怎么安装的?我用brew安装连接失败

AmdRyZen commented 2 months ago

brew 和 make 我都试了 都是一样的

image
an-tao commented 2 months ago
截屏2024-04-13 19 20 44

动态的没问题,static的编译报错

AmdRyZen commented 2 months ago

对 所以我在三方网站上看见的 ,我就试了一下就报错。 现在这个问题 我看是 用了static ,报内存问题 还是那个 读取confJson 里面jsoncpp 解析的 image

image

AmdRyZen commented 2 months ago

所以他的 demo也跑不过

an-tao commented 2 months ago

https://github.com/TechEmpower/FrameworkBenchmarks/pull/8875 tfb上static可以过CI

AmdRyZen commented 2 months ago

那我们这个是版本太高还是什么问题 没找到原因? 我本地 static 不加载 conf.json 也是没问题的

an-tao commented 2 months ago

jsoncpp你怎么安装的?

AmdRyZen commented 2 months ago

jsoncpp 我因为用gcc 所以我是本地编译的
mac 如果brew 安装 的话不支持gcc 只支持 Apple clang jsoncpp 长期不更新 不支持 13.2 所以我用 11.4 编译的

image image
AmdRyZen commented 2 months ago

我觉得jsoncpp 长期不跟新 应该在某个版本换掉 至于换什么 征求一下大家的意见

AmdRyZen commented 2 months ago

我试了一下1000次序列化 rapidjson 比 protobuf 性能还好

image
AmdRyZen commented 2 months ago

亲 什么情况了

an-tao commented 2 months ago

看不出来,太底层了,我的环境连static库,能编译,但是跑起来会崩。

AmdRyZen commented 2 months ago

对 我手动编译也没问题 就是不能跑 从clion调试结果来看 应该是内存泄漏问题
而且和jsoncpp 有关系
讲道理 有没有替换jsoncpp 的计划 现在 newHttpJsonResponse 强制绑定 jsoncpp

an-tao commented 2 months ago

对 我手动编译也没问题 就是不能跑 从clion调试结果来看 应该是内存泄漏问题 而且和jsoncpp 有关系 讲道理 有没有替换jsoncpp 的计划 现在 newHttpJsonResponse 强制绑定 jsoncpp

早就有人提出了,不好改,API变了,会影响老用户。权宜之计:可以用FromRequest模板适配你喜欢的json库,改的话得drogon2了

AmdRyZen commented 2 months ago

那等你好消息 2 的话 把这些七七八八的 都升级一下 最好 coroSql 在加一个 动态sql 和 go 一样那种 写起来就很舒服
if aa != nil { db = db.where("aa = ?", aa) }