memory-management

Swift5 MacOS ImageResize memory issue

偶尔善良 提交于 2021-02-02 03:43:50
问题 I am new to Mac OS App Development with Swift. But I tried to make the simple ImageResizer app. I have to resize 50k images. After 10 hours, the memory has increased to nealy 120GB. I thought Swift also has Garbage collector. Why does it increase memory? I will show you my code. for i in 0..<paths.count { let path = paths[i] if let image = NSImage(contentsOf: path) { ... if self.resize(image: image, size: size, to: URL(fileURLWithPath: resizedImagePath)) { print("Image saved to \

Swift5 MacOS ImageResize memory issue

余生颓废 提交于 2021-02-02 03:43:48
问题 I am new to Mac OS App Development with Swift. But I tried to make the simple ImageResizer app. I have to resize 50k images. After 10 hours, the memory has increased to nealy 120GB. I thought Swift also has Garbage collector. Why does it increase memory? I will show you my code. for i in 0..<paths.count { let path = paths[i] if let image = NSImage(contentsOf: path) { ... if self.resize(image: image, size: size, to: URL(fileURLWithPath: resizedImagePath)) { print("Image saved to \

using map to cache for around 5000 entries in Javascript apllication VS Redis

我们两清 提交于 2021-01-29 20:49:08
问题 I have a PRICE_MAPPER table at my DB It has around 5000 entries Price is determined on 3 entry types A B C ---> 300 (col1:A , col2:B , col3:C , colPrice:300) X Y Z ---> 500 .. and around 5000 of such entries (3 unique combinations determining a price) Planning to put these in a MAP at my Nodejs application Concern : I need advice, putting such a heavy data at my Nodejs application, would that be good decision or bad, as Nodejs is not for memory intensive tasks. I can cache this data at REDIS

Does the virtual memory of a process ever shrink?

不打扰是莪最后的温柔 提交于 2021-01-29 17:17:40
问题 Does the virtual memory of a process ever shrink?. Does the swap size of the process reduce? 回答1: Virtual memory, today with tons of dirty cheap RAM, is used more for memory protection than for swapping on PC. So there is no 1:1 correlation between used swap and virtual memory. And with 64bits addresses there is no need for the OS to claim back unused virtual memory pages. It'll do it if it needs to. If by swap size , you mean the swap column in top , that's not used swap, but the required

Stack and Heap about memory address question

▼魔方 西西 提交于 2021-01-29 15:59:59
问题 I knew what is stack and heap, but when I did some experiments on this topic, I found something surprising. int i,j; std::cout<< &i << "\n"; std::cout<< &j << "\n"; Results: 0x7a893a29e5b8 0x7a893a29e5bc That means stack is toward to high address, and not to low address which is shown by below graph. 来源: https://stackoverflow.com/questions/61540247/stack-and-heap-about-memory-address-question

Safe writing to variable in cython c wrapper within two python processes or distinct memory for python processes

ⅰ亾dé卋堺 提交于 2021-01-29 09:53:40
问题 I am creating a wrapper over c library that recieves some financial data and I want to collect it into python data type (dict with list of field names and list of lists with financial data fields). On the c level there is function that starts "listening" to some port and when any event appears some user-defined function is called. This function is written in cython. Simplified example of such function is here: cdef void default_listener(const event_data_t* data, int data_count, void* user

How to feed a conv2d net with a large npy file without overhelming the RAM memory?

丶灬走出姿态 提交于 2021-01-29 07:36:25
问题 I have a large dataset in a .npy format of size (500000,18). In order to feed it in a conv2D net using a generator I slipt in in X and y and reshape it in the format (-1, 96, 10, 10, 17) and (-1, 1), respectively. However, when I feed it inside the model I get and memory error: 2020-08-26 14:37:03.691425: I tensorflow/core/common_runtime/bfc_allocator.cc:812] 1 Chunks of size 462080 totalling 451.2KiB 2020-08-26 14:37:03.691432: I tensorflow/core/common_runtime/bfc_allocator.cc:812] 1 Chunks

Matrix/Vector initialization performance

こ雲淡風輕ζ 提交于 2021-01-29 05:29:30
问题 This is more of an educational question, there is no specific problem I am trying to solve. I would like some insight into what happens "behind the scenes" in the following scenario: We have 2 int s, w and h , and we need a matrix ( vector<vector<int>> ) of 0 s. There are multiple ways to do this and I would like to know which one performs best (probably this means which one performs the least copies). Option 1: vector<vector<int>> m; for (int i = 0; i < h; i++) { m.push_back(vector<int>());

Property is unable to set to nil via weak reference [duplicate]

安稳与你 提交于 2021-01-29 03:56:58
问题 This question already has answers here : Weak references in Swift playground don't work as expected (5 answers) Closed 4 years ago . The following code defines Person and Apartment . Person instance may own an Apartment , Apartment may have a tenant( Person instance) class Person { let name: String init(name: String) { self.name = name } var apartment: Apartment? deinit { print("\(name) is being deinitialized") } } class Apartment { let unit: String init(unit: String) { self.unit = unit }

Local variables and memory in c

二次信任 提交于 2021-01-29 03:04:17
问题 I'm somewhat new to C and am wondering about certain things about memory allocation. My function is as follows: size_t count_nwords(const char* str) { //char* copied_str = strdup(str); // because 'strtok()' alters the string it passes through char copied_str[strlen(str)]; strcpy(copied_str, str); size_t count = 1; strtok(copied_str, " "); while(strtok(NULL, " ") != 0) { count++; } //free(copied_str); return count; } This function counts the amount of words in a string (the delimiter is a