memory

Python, memory error, csv file too large [duplicate]

允我心安 提交于 2021-01-28 04:05:27
问题 This question already has answers here : Reading a huge .csv file (7 answers) Closed 6 years ago . I have a problem with a python module that cannot handle importing a big datafile (the file targets.csv weights nearly 1 Gb) the error appens when this line is loaded: targets = [(name, float(X), float(Y), float(Z), float(BG)) for name, X, Y, Z, BG in csv.reader(open('targets.csv'))] traceback: Traceback (most recent call last): File "C:\Users\gary\Documents\EPSON STUDIES\colors_text_D65.py",

Python, memory error, csv file too large [duplicate]

此生再无相见时 提交于 2021-01-28 03:44:43
问题 This question already has answers here : Reading a huge .csv file (7 answers) Closed 6 years ago . I have a problem with a python module that cannot handle importing a big datafile (the file targets.csv weights nearly 1 Gb) the error appens when this line is loaded: targets = [(name, float(X), float(Y), float(Z), float(BG)) for name, X, Y, Z, BG in csv.reader(open('targets.csv'))] traceback: Traceback (most recent call last): File "C:\Users\gary\Documents\EPSON STUDIES\colors_text_D65.py",

Is there a safer way to use unions to convert between integer and floating-point numbers?

对着背影说爱祢 提交于 2021-01-28 03:43:33
问题 I´m writing a VM in Rust and I have a C and C++ background. I need union-like functionality because on the VM stack I can either store an int or a float . In C I had a union: union stack_record_t { int i; float f; }; I can use the record as int or as float with zero runtime overhead. I have a static bytecode analyzer which will find type errors before the bytecode executes, so I don't have to store a flag alongside the record. I don´t know if it is a good idea to use unions in Rust because

How to clear memory completely of all Matplotlib plots

こ雲淡風輕ζ 提交于 2021-01-28 03:10:18
问题 I have data analysis module that contains functions which call on Matplotlib pyplot API multiple times to generate up to 30 figures in each run. These figures get immediately written to disk after they are generated, and so I need to clear them from memory. Currently, at the end of each of my function, I do import matplotlib.pyplot as plt plt.clf() however I'm not too sure if this statement can actually clear the memory. I'm especially concerned since I see that each time I run my module for

Efficient way to extract and collect a random subsample of a generator in Julia

此生再无相见时 提交于 2021-01-28 02:45:37
问题 Consider a generator in Julia that if collected will take a lot of memory g=(x^2 for x=1:9999999999999999) I want to take a random small subsample (Say 1%) of it, but I do not want to collect() the object because will take a lot of memory Until now the trick I was using was this temp=collect((( rand()>0.01 ? nothing : x ) for x in g)) random_sample= temp[temp.!=nothing] But this is not efficient for generators with a lot of elements, collecting something with so many nothing elements doesnt

Avoid dumping information in a core file

霸气de小男生 提交于 2021-01-28 02:05:25
问题 I want to avoid dumping certain information from my program into a core file in case of any crash. For that, I can use coredump_filter (http://man7.org/linux/man-pages/man5/core.5.html) The man page provides following description The value in the file is a bit mask of memory mapping types (see mmap(2)). If a bit is set in the mask, then memory mappings of the corresponding type are dumped; otherwise they are not dumped. The bits in this file have the following meanings: bit 0 Dump anonymous

What is the difference between memory leak, accessing freed memory and double free?

落花浮王杯 提交于 2021-01-28 00:13:09
问题 I'm trying to figure out what is the difference between those three kinds of problems associated with memory models. If I want to simulate a memory leak scenario, I can create a pointer without calling corresponding delete method. int main() { // OK int * p = new int; delete p; // Memory leak int * q = new int; // no delete } If I want to simulate a double free scenario, I can free a pointer twice and this part memory will be assigned twice later. a = malloc(10); // 0xa04010 b = malloc(10); /

How much memory is used when allocating an array vs allocating an linked list in Java?

若如初见. 提交于 2021-01-28 00:02:58
问题 My guess is its a 32-bit/64-bit word (depending on the CPU) per value stored in the array. So it would be array size X 32-bit/64-bit. In the case of linked lists, it would be twice this to store the reference which points to the next element. So it would be 2 * array size X 32-bit/64-bit. Is this correct, am I missing anything? 回答1: Much more. Each element in a linked list has: Pointer to next element, pointer to previous element, pointer to item value (12 bytes) + object overhead (around

should i free the memory i copied to clipboard?

这一生的挚爱 提交于 2021-01-27 14:19:35
问题 When I copy data in my win32 program to the clipbord, should i free the memory i copied to clipboard, after I paste it elsewhere? or the system is responsible for this. 回答1: It is generally done by the system however, some responsible applications also take care of asking the user to free up the clipboard before leaving. e.g. MSWord will ask the user to keep the data in memory or not before it quits. For general purpose, you can leave it to system. Remember here that user might want to keep

Generation 1 Heap Consuming Gigs of Memory as Free Space

安稳与你 提交于 2021-01-27 12:40:55
问题 We've had a long term issue with one of our products consuming GBs of memory when in production. We often get low memory warnings on the server, and finally today I finally had chance to sit down with a memory profiler and see where the memory is going. In development, with the same database and config, the application's private working set is 450MB. On the production server, the amount of memory allocated to that process is 3.7GB. Using Ants Memory Profiler, I determined that 2.906GB of that