memory

Calling delete on original buffer of char type after casting .c++

混江龙づ霸主 提交于 2020-12-05 12:29:26
问题 in this answer: https://stackoverflow.com/a/222578/4416169 with this code: char *buf = new char[sizeof(string)]; // pre-allocated buffer string *p = new (buf) string("hi"); // placement new string *q = new string("hi"); // ordinary heap allocation there is a comment that says: keep in mind that the strings are destrcuted manually before deleting the buffer, thats what the comment below already assumes. Strictly, it's undefined behaviour to call delete[] on the original char buffer. Using

Does accessing a single struct member pull the entire struct into the Cache?

笑着哭i 提交于 2020-12-01 07:21:02
问题 I've been reading Ulrich Drepper's, "What every programmer should know about memory" and in section 3.3.2 Measurements of Cache Effects ( halfway down the page ) it gives me the impression that accessing any member of a struct causes the whole struct to get pulled into the CPU cache. Is this correct? If so, how does the hardware know about the layout of these structs? Or does the code generated by the compiler somehow force the entire struct to be loaded? Or are the slowdowns from using

Does accessing a single struct member pull the entire struct into the Cache?

試著忘記壹切 提交于 2020-12-01 07:17:51
问题 I've been reading Ulrich Drepper's, "What every programmer should know about memory" and in section 3.3.2 Measurements of Cache Effects ( halfway down the page ) it gives me the impression that accessing any member of a struct causes the whole struct to get pulled into the CPU cache. Is this correct? If so, how does the hardware know about the layout of these structs? Or does the code generated by the compiler somehow force the entire struct to be loaded? Or are the slowdowns from using

How to handle Vue 2 memory usage for large data (~50 000 objects)

微笑、不失礼 提交于 2020-11-30 04:09:53
问题 I'm trying to implement an table-view for large collections of semi-complex objects on Vue 2. Basically the idea is to collect anywhere between 50 000 to 100 000 rows from DB into JS cache, which is then analyzed dynamically to build table-view with real-time-filters (text-search). Each row within table is toggleable, meaning that clicking the row changes the row to edit-mode, which enables Excel-like editing for that specific field/cell. Each object has about ~100-150 fields/properties, but

How to handle Vue 2 memory usage for large data (~50 000 objects)

戏子无情 提交于 2020-11-30 04:09:25
问题 I'm trying to implement an table-view for large collections of semi-complex objects on Vue 2. Basically the idea is to collect anywhere between 50 000 to 100 000 rows from DB into JS cache, which is then analyzed dynamically to build table-view with real-time-filters (text-search). Each row within table is toggleable, meaning that clicking the row changes the row to edit-mode, which enables Excel-like editing for that specific field/cell. Each object has about ~100-150 fields/properties, but

Double delete of data doesn't crash

不想你离开。 提交于 2020-11-29 07:05:53
问题 I am trying to learn C++ and was writing programs to learn Copy Constructors and Operator overloading. I am surprised that the below program when Copy constructor is used doesn't crash saying "Double Free", whereas when using Operator = overloading crashes consistently. #include <iostream> using namespace std; class XHandler { public: XHandler() { data = new char[8]; strcpy(data, "NoName"); } XHandler (const char *str) { data = new char (strlen(str) + 1 ); strcpy (data, str); } XHandler