A survey of task allocation and load balance in distributed system阅读笔记

本次分享主要围绕实验室老师分配的一篇英文文献展开,该文献作为分布式系统研究的基础,旨在引导深入理解并整理关键知识点。

实验室的老师扔给我一篇英文文献,作为毕设对分布式系统研究的开端要求仔细阅读并做好阅读笔记,顺便放在博客里方便以后查阅。
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

The references do not directly mention memory allocation and deallocation functions that should not be used. However, in general programming practices, some functions may be considered less favorable in certain scenarios. For example, in C++, while `malloc` and `free` from the C standard library can be used for memory allocation and deallocation, they are generally not recommended when working with C++ classes and objects. `malloc` only allocates raw memory and does not call the constructor of the object, and `free` only deallocates the memory without calling the destructor. In contrast, `new` and `delete` (or `new[]` and `delete[]`) in C++ are designed to handle object construction and destruction properly. Using `malloc` and `free` for C++ objects can lead to issues such as uninitialized objects and memory leaks due to non - called destructors [^1][^3]. Another aspect is that using `new` and `delete` inappropriately can also cause problems. For instance, if you allocate an array with `new[]`, you must use `delete[]` to deallocate it. Using `delete` instead of `delete[]` when dealing with an array allocated by `new[]` can result in undefined behavior, typically memory leaks and potential crashes [^3]. ```cpp #include <iostream> class MyClass { public: MyClass() { std::cout << "Constructor called" << std::endl; } ~MyClass() { std::cout << "Destructor called" << std::endl; } }; int main() { // Bad practice: using malloc for a C++ object MyClass* obj = (MyClass*)malloc(sizeof(MyClass)); // Constructor is not called here free(obj); // Destructor is not called here // Correct way in C++ MyClass* obj2 = new MyClass(); delete obj2; // Bad practice: incorrect deallocation of array MyClass* arr = new MyClass[5]; delete arr; // Should be delete[] arr; return 0; } ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值