V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  YsHaNg  ›  全部回复第 67 页 / 共 106 页
回复总数  2109
1 ... 63  64  65  66  67  68  69  70  71  72 ... 106  
2024-05-24 21:36:50 +08:00
回复了 honeygeek 创建的主题 NAS 群晖 920+的 M2 接口问题
@honeygeek 记得内存单颗粒不要大于 1Gb
2024-05-21 22:58:52 +08:00
回复了 zhouyin 创建的主题 美酒与美食 每餐吃土司
@xu455255849 白人饭上瘾患者真的觉得这很好吃 还有夹熟牛肉片 夹 tuna 拌蛋黄酱 省时 开火炒菜什么的经常做饭 1 小时吃饭 5 分钟
2024-05-18 08:55:01 +08:00
回复了 ilook 创建的主题 生活 关于记账,为什么不通过支付宝微信账单自动统计?
用各种 debit credit card 没用过微信支付 支付宝一年用一次 你确定世界上只有中国吗
2024-05-18 08:50:10 +08:00
回复了 Tumblr 创建的主题 NAS 想买个 NAS,群晖 DS923+可?
@Salvin 有公网 qc 是直连 跑满上行和 ddns 速度没差别
2024-05-18 08:44:31 +08:00
回复了 laters 创建的主题 Visual Studio Code vscode 远程开发好用吗 ?
很好用
2024-05-16 20:34:41 +08:00
回复了 albert0yyyy 创建的主题 C++ C++新手,求教为啥程序跑起来的内存越用越多
@albert0yyyy RAII+smart ptr 多用 auto 会让生活好很多
2024-05-16 20:32:20 +08:00
回复了 Div1ne 创建的主题 职场话题 你们现在的工资,跟刚入行时候的工资差了多少倍?
@Tifou 2 年 3 家😂 3 倍
2024-05-16 20:28:37 +08:00
回复了 albert0yyyy 创建的主题 C++ C++新手,求教为啥程序跑起来的内存越用越多
TL;DR 扔给 GPT 了
Yes, there are several memory leaks in the provided code. Let's go through them:

1. In the loop where you receive messages via the socket, you allocate memory for `receiveData` using `cJSON_Print`, but you don't free it. You should free it after you're done using it.

2. Similarly, you create a `cJSON` object using `cJSON_Parse`, but you don't free it using `cJSON_Delete`.

3. You allocate memory for `json_str` using `cJSON_Print`, but you don't free it after sending it over the socket.

4. You allocate memory for `input` and `output` inside the loop, but you don't free them before the next iteration of the loop. This can lead to memory leaks if `input` or `output` fail to initialize.

To fix these memory leaks:

- Free `receiveData` after its use with `SAFE_DELETE(receiveData)`.

- Delete the `cjson_receive` object using `cJSON_Delete` after its use.

- Free `json_str` after sending it over the socket.

- Delete `input` and `output` objects at the end of each iteration of the loop before reinitializing them.

Here's how you can do it:

```cpp
SAFE_DELETE(receiveData);
cJSON_Delete(cjson_receive);
SAFE_DELETE(json_str);
SAFE_DELETE(input);
SAFE_DELETE(output);
```

Place these lines at appropriate locations in your code to ensure memory allocated dynamically is properly deallocated.
2024-05-15 16:55:39 +08:00
回复了 Dandelion2333 创建的主题 长沙 大龄长沙女生找对象
@hanlin85 年薪 40 还在长沙那不就是减分项了
2024-05-15 16:54:17 +08:00
回复了 Dandelion2333 创建的主题 长沙 大龄长沙女生找对象
发现期待对象没有限定性别
2024-05-15 16:39:30 +08:00
回复了 soupure 创建的主题 问与答 如何把手机上复制的东西快速发到电脑上,求救
2024-05-13 05:21:42 +08:00
回复了 ttentau1 创建的主题 分享发现 分享一下我是怎么使用平板看油管的
@efcndi 浏览器插件去广告
1.专门的维护岗 开发 deploy 完了就不再负责 2.轮岗 oncall 轮到的同学发额外一天 oncall 钱 没事基础有事翻个番 自然有人抢着要
2024-05-10 17:04:44 +08:00
回复了 wsg123 创建的主题 求职 27 岁的 Android 开发找工作也好难
你又不肯润 在这既要又要
2024-05-10 17:03:04 +08:00
回复了 dululu 创建的主题 问与答 你知道有哪些职业有不为外人知的“福利”?
迪士尼影业的人有一年 4 次带朋友玩任意乐园
@moudy 你可以一切都远程 ssh 上去
2024-05-08 16:43:33 +08:00
回复了 milkzizi 创建的主题 iPad 请教一下 iPad 的真实使用场景
ios 上有 Termius
1 ... 63  64  65  66  67  68  69  70  71  72 ... 106  
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   5692 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 53ms · UTC 02:31 · PVG 10:31 · LAX 18:31 · JFK 21:31
♥ Do have faith in what you're doing.