memory

C++ memory leak with class members

南笙酒味 提交于 2020-01-05 06:50:34
问题 Debug_VLD in VS2010 reveals some memory leaks that come from class member creation / initialization / deletion. my_member is a data member with type double*. In constructor, I have my_member = NULL ; Then in some method, i need to allocate memory for my_member . I cannot do so in constructor, since i dont know size of array yet, and/or size may different for different calls of the method. What i do in this method is checking if member is NULL. if so, i allocate space for it, if not, i can

曹大谈内存重排

淺唱寂寞╮ 提交于 2020-01-05 03:38:18
目录 什么是内存重排 CPU 重排 编译器重排 为什么要内存重排 内存重排的底层原理 总结 参考资料 写这篇文章的原因很简单,公司内部的 Golang 社区组织了第一期分享,主讲嘉宾就是我们敬爱的曹大。这个必定是要去听的,只是曹大的讲题非常硬核,所以提前找他要了参考资料,花了 1 个小时提前预习,才不至于在正式分享的时候什么也不懂。当然了,这也是对自己和主讲者的尊重。所有的参考资料都在文章最后一部分,欢迎自行探索。 在我读曹大给我的中英文参考资料时,我发现英文的我能读懂,读中文却很费劲。经过对比,我发现,英文文章是由一个例子引入,循序渐进,逐步深入。跟着作者的脚步探索,非常有意思。而中文的博客上来就直奔主题,对于第一次接触的人非常不友好。 两者就像演绎法和归纳法区别。国内的教材通常是演绎法,也就是上来先讲各种概念、原理,再推出另一些定理,比较枯燥;国外的教材更喜欢由例子引入,步步深入,引人入胜。这里,不去评判孰孰劣。多看看一些英文原版材料,总是有益的。据我所知,曹大经常从亚马逊上购买英文书籍,这个侧面也可以反映曹大的水平高啊。据说英文书一般都很贵,可见曹大也是很有钱的。 所以啊,技术文章写好不容易,我也自省一下。 什么是内存重排 分两种,硬件和软件层面的,包括 CPU 重排、编译器重排。 CPU 重排 引用参考资料 【内存一致模型】 里的例子: 在两个线程里同时执行上面的代码,A

Getting address of data variable in x86 AT&T Assembly

旧街凉风 提交于 2020-01-05 03:32:13
问题 Possible duplicate exist, but I couldnt figure out how to apply this or othere solutions to similar problems so here I am. I am creating a function that returns and integer as a string in x86 AT&T Assembly. I have this code to declare the variable resdes . .data .align 4 resdes: .long 12 resdes now points to a memory location followed by 11 other bytes free for me to use (I have understood this correctly?). I want to load one digit at a time from the integer into the bytes one by one. this is

Structure not in memory

末鹿安然 提交于 2020-01-05 02:52:15
问题 I created a structure like that: struct Options { double bindableKeys = 567; double graphicLocation = 150; double textures = 300; }; Options options; Right after this declaration, in another process, I open the process which contains the structure and search for a byte array with the struct's doubles but nothing gets found. To obtain a result, I need to add something like std::cout << options.bindableKeys; after the declaration. Then I get a result from my pattern search. Why is this behaving

Available pagefile size / virtual memory

我与影子孤独终老i 提交于 2020-01-04 21:32:24
问题 What is the difference between Process.PagedMemorySize64 and PagedSystemMemorySize64 . I could not understand this clearly. Also , I am looking for a way to find out how much of the paging file is still availalbe. Do I have to loop through all the processes and sum up the PagedMemorySize64 for each one and subtract this from the total size of paging file ? 回答1: PagedSystemMemorySize64 is the total number bytes of operating system kernel memory in the paged memory pool attributed to the

Memory Requirement/Utilization for MongoDB, Riak and HyperTable (or HBase)

雨燕双飞 提交于 2020-01-04 19:47:07
问题 I've evaluated most of the NoSQL solutions and it seems that using a combination of MongoDB, Riak and HyperTable (or HBase) is the way to go. What is the minimum requirement for these databases to run comfortably? Let's say, if I deploy these databases (MongoDB, Riak and HyperTable - or HBase) - and Web Server (such as nginx or Cherokee) and Java/GlassFish - ALL on a single-machine running FreeBSD with 32 GB of RAM, how will they perform? Note that by going with this approach, the entire 32

running out of memory from for loop

不想你离开。 提交于 2020-01-04 19:01:54
问题 Hey so i thought it would be cool if i made a little app that generated a random password and then had the app run through all the possibilities and try to see what the password was tell me how many times it attempted it. Sometime the app works sometimes it crashes depends on what the password is. I wanted to know f there was anything i could do to stop it from crashing by using up to much memory. This is the method. -(void)hackString { NSString *string; NSString *string1; NSString *string2;

running out of memory from for loop

我的梦境 提交于 2020-01-04 19:01:10
问题 Hey so i thought it would be cool if i made a little app that generated a random password and then had the app run through all the possibilities and try to see what the password was tell me how many times it attempted it. Sometime the app works sometimes it crashes depends on what the password is. I wanted to know f there was anything i could do to stop it from crashing by using up to much memory. This is the method. -(void)hackString { NSString *string; NSString *string1; NSString *string2;

Can R do operations like cumsum in-place?

瘦欲@ 提交于 2020-01-04 16:57:23
问题 In Python I can do this: a = np.arange(100) print id(a) # shows some number a[:] = np.cumsum(a) print(id(a)) # shows the same number What I did here was to replace the contents of a with its cumsum. The address before and after is the same. Now let's try it in R: install.packages('pryr') library(pryr) a = 0:99 print(address(a)) # shows some number a[1:length(a)] = cumsum(a) print(address(a)) # shows a different number! The question is how can I overwrite already-allocated memory in R with the

Why do subsequent Rust variables increment the stack pointer instead of decrementing it?

这一生的挚爱 提交于 2020-01-04 15:53:49
问题 I find it odd how when you create statically-allocated variables in Rust that it seems as the stack pointer increases. I know this is not the case since the stack pointer decreases as memory is allocated. If I were to do the same thing in C, I would see the stack pointer decrease as I created more variables. Why is it this way? Does the Rust compiler allocate these from bottom to top instead on top to bottom? fn main() { let i1 = 1; let i2 = 1; let i3 = 1; println!("i1 : {:?}", &i1 as *const