Tag:Allocate memory

  • C++ placement new learning

    Time:2022-8-4

    Usually, the new operation is used to create objects, but this cannot specify to open up space in a specific block of memory to create objects. And if You can specify the memory location to open up space. We can write a memory pool to reuse the same memory location efficiently, which can avoid the […]

  • Which do you use to allocate memory in go language, new or make?

    Time:2022-6-17

    Link to the original text: which do you use to allocate memory in go language, new or make? preface Hello, everyone. I am a pigeon that has been dragging on for a long timeasong。 because5.1I went to find my girlfriend, so I didn’t have time to write an article. I thought I would hurry up […]

  • Study day 17

    Time:2022-4-12

    C language Local variables Variables defined in the function can only be used in this function Other functions can be called, but other functions still cannot use the caller’s variables Different functions can use variables with the same name, complementary interference Formal parameters can also be regarded as local variables Variables defined in a compound […]

  • Study day 19

    Time:2022-4-7

    C language Macro definition without parameters Used to replace — string replacement identifier Identifiers are also called macro names # define a 78 int main() { printf(“%d\n”, a); } # define a 78 int main() { int b; b = 3 * a; printf(“%d\n”,b); } The process of replacing a string with a macro name […]

  • Redis source code memory management allocation

    Time:2022-3-29

    1、 Memory management filezmalloc.h/.c 2、 Code implementation void *zmalloc(size_t size) { void *ptr = malloc(size+PREFIX_SIZE); if (!ptr) zmalloc_oom_handler(size); #ifdef HAVE_MALLOC_SIZE update_zmalloc_stat_alloc(zmalloc_size(ptr)); return ptr; #else *((size_t*)ptr) = size; update_zmalloc_stat_alloc(size+PREFIX_SIZE); return (char*)ptr+PREFIX_SIZE; #endif } Before looking at the code, I always thought have_ MALLOC_ If size is not defined, it follows the above branches. After checking the […]

  • JS interview related

    Time:2022-1-18

    How to define variables There are two types of Es5: VaR and function There are 6 kinds of ES6 Four types are added: let, const, import and class.Note: the global variables declared by let, const and class will no longer be linked to the properties of the global object closure Closures are functions that can […]

  • New and malloc, free store and heap | handling understanding and sorting

    Time:2021-12-24

    Free storage and heap placement-new、new operator、operator new difference Demo1: operator new / operator delete New and malloc Free storage and heap reference resources:https://stackoverflow.com/que… reference resources:https://www.quora.com/What-is… reference resources:https://www.cnblogs.com/qg-wh… reference resources:https://blog.csdn.net/nie1994… Two dynamic memory regions. heap free store C + + memory layout Pile(malloc/free), stack, free storage(new delete), global / static storage, constant storage The difference between […]

  • Quickly build linux (LNMP + Linux Installation + environment configuration)

    Time:2021-12-19

    Notes: Recently, I was learning how to make MySQL highly available. I needed multiple MySQL servers. When I first built it, I followed my notes step by step. On the whole, it took about 3 hours (installation system + environment construction + other configurations), which was quite goodtime consuming。 When I built the third platform, […]

  • Linux oom mechanism

    Time:2021-11-21

    Previously, the project team cooperated in the development of a 1-core 1g development server with nginx, PHP, MySQL and other programs that did not consume resources. With the rise of test data and the increase of developers (MySQL visual chemical tool long connection will also consume memory), the MySQL process often hung up. At that […]

  • Remember to start oom troubleshooting for k3s MySQL once

    Time:2021-11-7

    Previously, docker compose was used as the development environment, and MySQL was also running in docker. Everything was working normally. Later, the development environment was migrated to k3s (lightweight k8s), but MySQL was killed by oom killer as soon as MySQL was started, so MySQL has not been migrated. reproduce Run a MySQL directly using […]

  • [. Net core knowledge review] – automatic memory management

    Time:2021-11-4

    Automatic memory management is one of the services provided by the common language runtime during managed execution. The garbage collector of the common language runtime manages memory for applications Distribution and release of. For developers, it is not necessary to write code to perform memory management tasks when developing managed applications. Allocate memory When a […]

  • Implement a simple STL allocator

    Time:2021-10-24

    1. General This paper implements a simple allocator and briefly explains the internal implementation process of new / delete. 2. A simple STL allocator STL allocator is the space configurator in the container. STD:: allocator is the default of the standard library. Its main functions are memory allocation and release, object construction and deconstruction. It […]