memory

vector<string> does not clear memory after out of scope

淺唱寂寞╮ 提交于 2020-01-14 08:48:05
问题 i've encountered the following problem, and i'm not really sure whether i am wrong or its a really weird bug. I fill a huge array of strings and want it to be cleared at a certain point. Here's a minimal example #include <string> #include <vector> #include <unistd.h> //sleep #include <iostream> int main(){ { std::vector<std::string> strvec; for(long i = 0; i < 1000000; ++i){ std::string out = "This is gonna be a long string just to fill up the memory used by this fucking pthread\n"; strvec

XLConnect Java Virtual Machine out of memory error

泪湿孤枕 提交于 2020-01-14 04:52:06
问题 I know this issue has been visited several times, but I haven't found the solution to my problem: I reserve 1024 MB for the virtual machine with > options(java.parameters = "-Xmx1024m") > library(XLConnect) xlcMemoryReport finds only around 15 MB and xlcFreeMemory doesn't help (actually sometimes further reduces available memory) > xlcMemoryReport() Amount of free memory in the Java Virtual Machine (JVM): 14.79472 MB > xlcFreeMemory() > xlcMemoryReport() Amount of free memory in the Java

Do nvcc, gcc, clang and msvc “respect” the __restrict__ keyword within structs?

谁都会走 提交于 2020-01-14 04:38:08
问题 Suppose I have struct s { int* __restrict__ p1; double v; }; void foo(int* __restrict__ p2, struct s my_s) { /* ... */ } Do the C++ compilers listed below respect the __restrict__ keywords in this case, and assume memory accesses through p2 cannot affect accesses through p1 ? Obviously this is compiler-dependent, since restrict is not a C++ keyword. I'm mainly interested in the answer for gcc 4.9.x and nVIDIA CUDA 7.5's nvcc (when compiling device code of course, not when forwarding to a host

incompatible return type from struct function - C

不羁岁月 提交于 2020-01-14 04:34:05
问题 When I attempt to run this code as it is, I receive the compiler message "error: incompatible types in return". I marked the location of the error in my code. If I take the line out, then the compiler is happy. The problem is I want to return a value representing invalid input to the function (which in this case is calling f2(2).) I only want a struct returned with data if the function is called without using 2 as a parameter. I feel the only two ways to go is to either: make the function

PHP cli Memory usage optimization

寵の児 提交于 2020-01-14 03:07:35
问题 I am trying to code a custom url_rewriter for squid. & also with using some other url_rewriter programs like squidGuard so have to use a wrapper to able use both or any other program. when i try to loop with php. (that's the way how squid communicates with external programs. STDIN/STDOUT. it gives you a url & you have to send the new one or old one back. ) it has a devastating memory usage even doing nothing. i've changed to wrap it with another bash script it is only a few lines. & it loops

Byte in Java Takes 4 bytes by default? [duplicate]

放肆的年华 提交于 2020-01-14 03:00:08
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Size of a byte in memory - Java I read this in an article. I am just pasting as is: The class takes up at least 8 bytes. So, if you say **new Object();** you will allocate 8 bytes on the heap. Each data member takes up 4 bytes, except for long and double which take up 8 bytes. Even if the data member is a byte, it will still take up 4 bytes! In addition, the amount of memory used is increased in 8 byte blocks.

java out of memory then exit

岁酱吖の 提交于 2020-01-14 02:07:46
问题 I have a piece of software that has to analyze big files. Constraining the input or giving infinite memory is not an option, so I have to live with flying OOMEs. Because the OOME only kills the Thread, my software runs in some crappy state. From outside everything looks okay because the process is running but on the inside it's braindead. I would like to pull the plug on it. But how can I do this? Catching a OOME does not guranteee that the next line of code will be executed. e.g System.exit

Javascript Freeing the DOM

主宰稳场 提交于 2020-01-14 00:31:11
问题 I've written a fairly large web app. It works good for awhile and then slowly starts running sluggish as DOM nodes start creeping around 80,000 - 100,000. So I've been screweing around with some small data sets in the Chrome Dev Tools console (DCTC). Can someone tell me why the following works sometimes and then sometimes it does not. var test = $('<div></div>'); test.remove(); test = null; //Doesn't seem to make a difference when it doesn't work If I watch the DOM node count under Timeline

What is raw memory in C & C++?

放肆的年华 提交于 2020-01-13 18:25:31
问题 Sorry for asking this question, but actually I don't know about this. I have read in the following FAQ entry: Can I free() pointers allocated with new? Can I delete pointers allocated with malloc()? Furthermore, there is no guarantee that the mechanism used by new and delete to acquire and release raw memory is compatible with malloc() and free() . I just want to know that what is this "raw memory"? 回答1: "Raw memory" refers to blocks of memory, treated as unstructured arrays of bytes. Higher

solidity学习——mapping

怎甘沉沦 提交于 2020-01-13 13:26:56
今天我们来学习下映射的用法,具体以网站的注册过程为例。 一、solidity中,映射的关键字为mapping,首先我们先来定义两个mapping, mapping(address =>uint) idmapping和mapping(uint =>string) namemapping。idmapping用来表示地址变量和整型变量的对应关系,在注册过程中用来表示账户地址和注册号;namemapping用来表示整型变量和字符串的对应关系,在注册过程中用来表示注册号和用户名称。 同时将sum的初始值设成1,用来储存注册号,并在后续调用注册函数时累加。用户调用注册函数时,需要传入参数name,同时将合约的部署地址赋值给账户地址(address account =msg.sender;),并通过两个mapping将账户地址和注册号,以及注册号和用户名称对应起来。 调用register之后,我们来测试下,可以通过getIdByAddress来获取注册号,通过getNameById来获取用户姓名。代码如下, pragma solidity^0.5.0; contract MapTest{ mapping(address =>uint) idmapping; mapping(uint =>string) namemapping; uint public sum=0; function