memory

How to detect memory leak when memory allocation number isn't always same?

浪尽此生 提交于 2020-01-15 09:52:35
问题 I got a memory leak (55 bytes) on my program like this. I am using C++, MFC, Visual Studio 2010. Detected memory leaks! {13497} normal block at 0x0E44C248, 55 bytes long. Data: 44 3A 5C 46 44 41 53.... the problem is, the memory allocation number "13497" is not always same. it's always different number if I run the program again. I wanted to find where I didn't release the memory before the exit, with _crtBreakAlloc, but it seems not possible to break on a memory allocation number. I used

Memory usage of DotNET app

强颜欢笑 提交于 2020-01-15 09:39:10
问题 My application (DotNET) runs as a plug-in inside a C++ standalone app that exposes a C++/CLI SDK. It is very easy for my users to generate large amounts of data and I'd like to offer an abort option if the memory consumption of my plug-in + the base application reaches -say- 90% of the legal maximum. How can I measure the total memory consumption (ideally for both the managed and unmanaged code) and how do I know how much memory windows allows for the current application? 回答1: The Process

Arrays memory allocation on stack

拜拜、爱过 提交于 2020-01-15 09:37:08
问题 I have 2 functions in C: void func1(unsigned char x) { unsigned char a[10][5]; a[0][0] = 1; a[9][4] = 2; } void func2(unsigned char x) { unsigned char a[10][5]; a[0][0] = 1; a[9][4] = 2; unsigned char b[10]; b[0] = 4; b[9] = 5; } Compiling with: gcc 7.3 x86-64 -O0 -g OS: 16.04.1-Ubuntu x86-64 Produced intel assembly of functions: func1(unsigned char): pushq %rbp movq %rsp, %rbp movl %edi, %eax movb %al, -68(%rbp) movb $1, -64(%rbp) movb $2, -15(%rbp) nop popq %rbp ret func2(unsigned char):

mysqli_result::free increase php memory usage

元气小坏坏 提交于 2020-01-15 07:18:08
问题 Sometimes memory_get_usage() return a bigger value after using free() . See the example below: $query = "SELECT * FROM table"; $result = self::query($query); while ($row = $result->fetch_assoc()) { $myArray[] = $row; } echo "Before: ".number_format(memory_get_usage()); $result->free(); echo "After: ".number_format(memory_get_usage()); The output is: Before: 1,203,856 After: 1,370,976 But if I comment the instruction in the loop then the memory usage decrease after the free() : $result = self:

mysqli_result::free increase php memory usage

一曲冷凌霜 提交于 2020-01-15 07:17:11
问题 Sometimes memory_get_usage() return a bigger value after using free() . See the example below: $query = "SELECT * FROM table"; $result = self::query($query); while ($row = $result->fetch_assoc()) { $myArray[] = $row; } echo "Before: ".number_format(memory_get_usage()); $result->free(); echo "After: ".number_format(memory_get_usage()); The output is: Before: 1,203,856 After: 1,370,976 But if I comment the instruction in the loop then the memory usage decrease after the free() : $result = self:

C++ How To Read First Couple Bytes Of Function? (32 bit Machine)

我只是一个虾纸丫 提交于 2020-01-15 06:38:13
问题 Let's say I have a function like this (completely random, I just wrote it up in like 30 seconds for an example) bool exampleAuthetnication(char *a, char *b) { bool didAuthenticate = false; if(strcmp(a, b) == 0) { didAuthenticate = true; } if(didAuthenticate) { return true; } else { stopExecutable(); return false; } } How would I go about reading the first few bytes of this function? I've come up with this int functionByteArray[10]; for (int i = 0; i < 10; i++) { functionByteArray[i] = *(int*)

Parsing large XML using iterparse() consumes too much memory. Any alternative?

ぃ、小莉子 提交于 2020-01-15 06:16:12
问题 I am using python 2.7 with latest lxml library. I am parsing a large XML file with very homogenous structure and millions of elements. I thought lxml's iterparse would not build an internal tree while it parses, but apparently it does since memory usage grows until it crashes (around 1GB). Is there a way to parse large XML file using lxml without using a lot of memory? I saw the target parser interface as one possibility, but I'm not sure if that will work any better. 回答1: Try using Liza Daly

Do properties/methods in classes take space in memory?

假如想象 提交于 2020-01-15 05:48:44
问题 If we had code like this: public class Enemy { public int hp; } Then an Enemy object would take 4 bytes in 32-bit machines, and 8 bytes in 64-bit (correct me if I'm wrong). If we change it to something like this: public class Enemy { public int hp; public void Attack() {} } An Enemy object would still take the same amount of memory as it did before, right? The same for this: public class Enemy { private int hp; public int Hp { get { return hp; } set { hp = value; } } } From what I know, a

Node redis publisher consuming too much memory

有些话、适合烂在心里 提交于 2020-01-15 05:11:28
问题 I wrote a small redis publisher in node by using node_redis library. After the program is done publishing 1M messages, it continues to hold up around 350 MB of memory. Can anyone provide any clues why the program requires so much memory and how the memory can be released? Following is the code snippet - var redis = require("redis"), publisher = redis.createClient(); var i = 0; for (;;) { publisher.publish("rChat", i); i++; if (i == 1000000) { console.log("stopped sending messages");

解决 Redis 只读不可写的问题

╄→гoц情女王★ 提交于 2020-01-15 02:29:53
本文转载: https://blog.csdn.net/han_cui/article/details/54767208?tdsourcetag=s_pcqq_aiomsg 解决 Redis 只读不可写的问题 在 Redis 终端上进行读写操作,发现只读不可写,GET 操作是正常的,SET 操作提示错误:(error)MISCONF Redis is configured to save RDB snapshots,but is currently not able to persist on disk. Commands that may modify the data set are disabled. 如图所示: 原因: Redis 在保存数据到硬盘时为了避免主进程假死,需要 Fork 一份主进程,然后在 Fork 进程内完成数据保存到硬盘的操作,如果主进程使用了 4 GB 的内存,Fork 子进程的时候需要额外的 4 GB,此时内存就不够了,Fork 失败,进而数据保存硬盘也失败了。 Linux 内核会根据参数 vm.overcommit_memory 参数的设置决定是否放行。 如果 vm.overcommit_memory = 1,直接放行。 vm.overcommit_memory = 0:则比较此次请求分配的虚拟内存大小和系统当前空闲的物理内存加上swap