memory

Instantiating C++ objects from QML has tremendous memory usage overhead

谁说我不能喝 提交于 2021-02-07 07:58:25
问题 Instantiating a QObject derived class on the heap in C++ gives me roughly about 160 bytes per object. Registering the same object via qmlRegisterType() for creation from QML and creating the object dynamically via createObject() gives me a little over 2000 bytes per object. That's quite the difference, almost 13 times more memory per object is being used when creating from QML. Note that the object doesn't have any bindings or anything extra compared to how it is in C++. Naturally, being

glibc detected malloc(): memory corruption in C

瘦欲@ 提交于 2021-02-07 06:48:18
问题 I am trying to compile and code written in C under linux, and got this error message: glibc detected malloc(): memory corruption and I cannot find out why... the substring() just return you part of the original string by giving the starting index and length. e.g. substring("this is example",0,4) = "this"; char *substring(char* str, int start, int length) { char *newString = (char *)malloc(length * sizeof(char)); int i, x = 0; int end=start+length-1; for(i = start ; i <= end; i++){ newString[x

gtkmm/c++ first hello world example leaking memory

一世执手 提交于 2021-02-07 06:26:10
问题 I'm trying to learn gtkmm, and decided to try gtkmm 2.4 for the time being since it seems to be pretty hard to get 3.0 working on Debian. Anyway, the example I'm trying is the one here: http://developer.gnome.org/gtkmm-tutorial/2.24/sec-helloworld.html.en. It compiles fine and it runs alright aswell, but when i close it valgrind reports a lot of leaks, something along the lines of this (after clicking the button once): ==4254== Memcheck, a memory error detector ==4254== Copyright (C) 2002

Best practices to determine stack usage in Ravenscar program

余生颓废 提交于 2021-02-07 06:26:07
问题 I am writing an Ada program using the Ravenscar subset (thus, I am aware of the number of running tasks at execution time). The code is compiled by gcc with the -fstack-check switch enabled. This should cause the program raise a STORAGE_ERROR at runtime if any of my tasks exceed their stack. Ada allows to set the upper limit for those (task-specific) stacks during the specification of the respective task like so: pragma Storage_Size (Some_Value); Now I was wondering what options I have to

gtkmm/c++ first hello world example leaking memory

走远了吗. 提交于 2021-02-07 06:25:09
问题 I'm trying to learn gtkmm, and decided to try gtkmm 2.4 for the time being since it seems to be pretty hard to get 3.0 working on Debian. Anyway, the example I'm trying is the one here: http://developer.gnome.org/gtkmm-tutorial/2.24/sec-helloworld.html.en. It compiles fine and it runs alright aswell, but when i close it valgrind reports a lot of leaks, something along the lines of this (after clicking the button once): ==4254== Memcheck, a memory error detector ==4254== Copyright (C) 2002

How to avoid OrderBy - memory usage problems

百般思念 提交于 2021-02-07 04:54:05
问题 Let's assume we have a large list of points List<Point> pointList (already stored in memory) where each Point contains X, Y, and Z coordinate. Now, I would like to select for example N% of points with biggest Z-values of all points stored in pointList . Right now I'm doing it like that: N = 0.05; // selecting only 5% of points double cutoffValue = pointList .OrderBy(p=> p.Z) // First bottleneck - creates sorted copy of all data .ElementAt((int) pointList.Count * (1 - N)).Z; List<Point>

Difference between memory and register

不羁的心 提交于 2021-02-07 04:35:13
问题 I saw assembly code like, MOV [EAX], EBX the above line, They are mentioned [EAX] is memory and EBX is Register. So, here what is the difference between [EAX] and EBX . What will happen in above instruction. 回答1: In this syntax, brackets around a register means a memory location is used (as source or destination, according to the instruction) with starting address specified at the register (EAX in your case). For example, if EAX contained 1344 before the instruction, value from EBX is copied

FileReader memory leak in Chrome

与世无争的帅哥 提交于 2021-02-07 03:51:40
问题 I have a webpage with file upload functionality. The upload is performed in 5MB chunks. I want to calculate hash for each chunk before sending it to the server. The chunks are represented by Blob objects. In order to calculate the hash I am reading such blob into an ArrayBuffer using a native FileReader. Here is the code: var reader = new FileReader(); var getHash = function (blob, callback) { reader.onloadend = function (e) { var hash = util.hash(e.target.result); callback(hash); }; reader

FileReader memory leak in Chrome

徘徊边缘 提交于 2021-02-07 03:49:40
问题 I have a webpage with file upload functionality. The upload is performed in 5MB chunks. I want to calculate hash for each chunk before sending it to the server. The chunks are represented by Blob objects. In order to calculate the hash I am reading such blob into an ArrayBuffer using a native FileReader. Here is the code: var reader = new FileReader(); var getHash = function (blob, callback) { reader.onloadend = function (e) { var hash = util.hash(e.target.result); callback(hash); }; reader

FileReader memory leak in Chrome

别来无恙 提交于 2021-02-07 03:49:26
问题 I have a webpage with file upload functionality. The upload is performed in 5MB chunks. I want to calculate hash for each chunk before sending it to the server. The chunks are represented by Blob objects. In order to calculate the hash I am reading such blob into an ArrayBuffer using a native FileReader. Here is the code: var reader = new FileReader(); var getHash = function (blob, callback) { reader.onloadend = function (e) { var hash = util.hash(e.target.result); callback(hash); }; reader