Questions tagged [memory-management]

12467 questions
1

votes
1

answer
79

Views

Contiguous allocated arrays in JavaScript/TypeScript with strings

I have a system that looks like this: interface Data { x: number; y: number; n: string; } const array = Array(100); I've read that in Chrome the V8 engine will allocate objects as C arrays if the array only contains the same type, but is it possible to actually check if my ´array´ object will act...
Frans Bstrom
1

votes
4

answer
88

Views

Why don't Android and iOS kill the process when the app is closed?

On Windows, MacOS and Linux, when an app is closed, the norm is that its process is also killed. This happens as default on Windows/ Linux, and on MacOS, it still seems like a good idea to press CMD+Q to kill the process when no app window is open. On Android (and iOS too) when the app is background...
farhanjk
1

votes
2

answer
369

Views

How does GCC implement the C++ standard allocator?

I am not familiar with tracking down the source codes to figure out the GCC STL implementation (libstdc++) of the C++ standard allocator, and I cannot find any brief explanation, documentation and technical reports that describe what the memory model that GCC selects. I guess that GCC uses several f...
Kevin Dong
5

votes
4

answer
140

Views

Does terminating a program reclaim memory in the same way as free()?

I saw this answer to a stack overflow question that says that freeing memory at the very end of a c program is actually harmful because it moves variables that wouldn't be used again into system memory. I'm confused why the free() method in C would do anything different than the operating system rec...
ngood97
1

votes
2

answer
49

Views

Does compiler optimization affect on dynamic memory allocation?

I know sometimes compilers remove unused arrays. But my question is do the affect on dynamic variables which are allocated using malloc or just the stack variables ? Is malloc a compile time operation or runtime? If it is runtime can compiler remove an array which is allocated using malloc or it can...
Ramtin Mousavi
1

votes
2

answer
55

Views

Cocoa class member variable allocated inside function call nil unless forced to init/load

I come from a C/C++ background and am currently learning a bit about Cocoa and Objective-C. I have a weird behavior involving lazy initialization (unless I'm mistaken) and feel like I'm missing something very basic. Setup: Xcode 10.1 (10B61) macOS High Sierra 10.13.6 started from a scratch Cocoa pro...
JLL
1

votes
2

answer
66

Views

Eigen::Map'd matrix from raw buffer gives OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG

Recently I have been working with Eigen matrices derived from raw buffers and I noticed this curious case: #include int main(int argc, char const *argv[]) { /* code */ const int M = 320; const int N = 640; const int K = 320; const int alpha = 2; const int beta = 1; Eigen::Matrix A = Eigen::Matrix::...
XapaJIaMnu
1

votes
3

answer
43

Views

Is it possible to allocate structs on the stack with its definition hidden in a source file?

I have the following header file: struct StackList_s; typedef struct StackList_s StackList_t; // From here I add in the method signatures And the following source file: struct StackList_s { integer_t count; struct StackListNode_s *top; // Here begins the linked list // Some other members that store...
LeoVen
1

votes
2

answer
4.1k

Views

How free memory immediately in iOS?

When you do a release, you do not immediately remove the memory. I used this code and I can see the memory before and after the use of release and it do not change. Ok, it will be release after some time. But, what can I do for release all memory I can before start a library that will use a lot of m...
Rodrigo
1

votes
1

answer
250

Views

Can I just use fixed arrays instead of memory pools?

Instead of making a memory pool system,can't I just allocate huge arrays for each object at the start of the application and just use them and in the extreme case some object does need more instances than it's array,the array will just get doubled or quadrupled in size,so it would never reach the ma...
user1779802
1

votes
0

answer
29

Views

Why Loading Images takes so much memory even though their sizes are 2KB

I have 5-6 PNG images each 2kb in size, and when i load them to my ImageView's, on Android Monitor it shows 12 MB more added to allocated memory. i don't know what other factors are there that takes so much memory. while i see other applications that are using many images per screen, they have no is...
garetHollamdaf
1

votes
0

answer
39

Views

MySQL: Retrieve millions of rows from multiple shards at the same time

We have 2 MySQL DBs(both tables in 16 shards) with 100M+ rows and growing/updating. For reporting purposes, I need to fetch all the rows(50M+) on a daily basis, from 1st DB I need to fetch all the rows(50M+) created on that day, from 2nd DB These rows might update/insertion can happen anytime. Requ...
Pankaj Singhal
1

votes
0

answer
142

Views

Crash when destroying weak_ptr, double destruction of weak_ptr's shared_ptr_emplace object

I'm running into a crash occasionally when the destructor of a weak_ptr is called. This is the precise crash log tests(35405,0x700002602000) malloc: *** error for object 0x7fcd2010a5b0: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug The pointer that it is...
Kartik Aiyer
1

votes
0

answer
62

Views

Use 2 malloc calls to define 1 array c

I am trying to make an unsigned char array in c++ that is ~ 4 gigabytes in size. The code I am using to malloc the space for the array is below: unsigned char *myArray= (unsigned char*)malloc(sizeof(char)*3774873600); if(myArray==NULL) { cout
YAHsaves
1

votes
0

answer
165

Views

invalid explicit template argument(s) xmemory()

The aforementioned error (C2770) has poped up for xmemory() file along with others like Error C2825 '_Ty': must be a class or namespace when followed by '::'. I have found some questions here and there about such error but none regarding xmemory() especially that I can't edit it... The error ar...
Peet
1

votes
1

answer
74

Views

Getting valgrind error in C code

I am running memory analysis using Valgrind on C code of the small application, that finds out all paths in a graph using DFS method. But I am still getting some errors, mainly in this part of code: int process_edges(VoidStack *edges, char *buffer) { char weight[DATE_LENGTH] = ''; char min_weight[DA...
awarus
1

votes
1

answer
115

Views

concatenate or vstack numpy arrays doubling memory

Some previous information I have the following method which loads two data sets from disk then combines them and returns the combined data set. def _get_data(self, data_set_name): training_data = DataSet.from_file('path_to_data_file','path_to_label_file') test_data = DataSet.from_file('path_to_data_...
Yannic Klem
1

votes
0

answer
15

Views

How to generate/find TPC workloads traces

I'm trying to evaluate a particular cache design on my own simulator. I need traces of read and write operations. I found out that TPC workloads are memory stressful and I'd like to use them for my design evaluation. I was wondering if the traces are available or I need to run them on particular sys...
samira
1

votes
1

answer
24

Views

Are there disadvantages of using __slots__?

I'm using Python 3.7 and Django. I was reading about '_slots__' -- http://book.pythontips.com/en/latest/slots__magic.html . Evidently, _slots can be used to optimize memory allocation for a large number of those objects by doing this ... class MyClass(object): __slots__ = ['name', 'identifier'] de...
Dave
1

votes
1

answer
49

Views

one physical page allocated when malloc() called

I was trying to find the virtual set size and resident set size of a c program. I wrote a kernel module to traverse the vm_areas and calculated vss and rss. I also wrote one c program to validate the changes in vss and rss. // sample test program #include #include #include #define N 10000000 int...
Debashish
1

votes
0

answer
71

Views

Better performance with Flink Gelly when decreasing available memory

I notice strange behavior in the performance of Flink Gelly (PageRank algorithm on a graph of approximately 17,000,000 vertices and 136,000,000 edges). While setting taskmanager.heap.mb: 125000 results to a runtime of ~110 sec, taskmanager.heap.mb: 10000 reduces the runtime by more than 50%. I unde...
rawrintheclouds
1

votes
0

answer
249

Views

Android Profiler shows others section taking a lot of memory than expected

I ran Android Profiler on my App since it was slow in simple user interactions. When I ran the profiler it showed 150 mib memory used by 'others' category. After searching on official forums here: https://developer.android.com/studio/profile/memory-profiler.html It says ' Memory used by your app tha...
Suyash Gupta
1

votes
0

answer
56

Views

Track memory-consumption of a part of a program for caching

I´m looking for an approach to keep track of memory-consumption from a part of my program. What I´m trying to achieve in the actual use-case is to write a cache-class with an upper size limit. Since the cached data is a rather complex hierarchy of some nested classes adding a getSize() methods to...
J. Mueller
1

votes
0

answer
23

Views

Stack allocation fail when close to heap

Issue Description C++ server got several crashes at the same stack frame as below enter image description here Investigation Memory was not used up, 400M-800M Stack space used is not large, about 270K-350K Haven't found any other code issue caused crash The distance between stack and heap is about 1...
oliver zhu
1

votes
0

answer
207

Views

Why does LibreOffice wants memory pages to be writable and executable in the same time?

OpenBSD has great features for Memory protection, ex.: W^X. https://en.wikipedia.org/wiki/W^X https://man.openbsd.org/mount We can disable this function with the 'wxallowed' mount option if a program needs it, and sadly, LibreOffice needs the wxallowed on /usr/local/. The Question: Can someone Ple...
Hessnov
1

votes
0

answer
259

Views

Monitor Spark execution and storage memory utilization

I know there are several ways to monitor storage memory utilization of a Spark application but does anyone know a way to monitor execution memory utilization. I am also looking for a way to monitor the 'user memory', that is memory that is not used for execution nor storage memory. Going by Spark's...
Antonio Ye
1

votes
1

answer
57

Views

Gem 5 Memory Allocation

I have made an x86 architecture on gem5. Now if we run an executable file with a memory allocation code using malloc then will this memory be allocated from my system or a virtual memory given to this x86 architecture.
Prakhar Gurawa
1

votes
1

answer
150

Views

Valgrind finding memory leak for string even after I free it

In my program I declare some nodes in a linked list: node_t* newSymbol = malloc(sizeof(node_t)); newSymbol->symbol.name = strdup(name); //name is a (const) char* that is a parameter to function I'm in. newSymbol->symbol.addr = addr; I use strdup because assigning the symbols name to the parameter di...
Bonfire184
1

votes
1

answer
511

Views

What is kernel dynamic memory in linux systems and how to free it

This question is related to https://serverfault.com/questions/896282/cannot-explain-memory-occupancy-in-linux/896525#896525 and to How to correctly identify and correct a memory leak on a server? What is kernel dynamic memory? I have virtually no process running in my workstation now $ ps aux --sor...
mox
1

votes
1

answer
1k

Views

React Native iOS app using large amount of memory

I'm building my first react native ios app. The main feature of this app is to make a request to a server, get data and render that in a FlatList. On initial load, 15 list items inside the FlatList are rendered, and when the user scrolls down, 15 more are added each time the user gets to the bottom...
Luka Kerr
1

votes
1

answer
49

Views

C, garbage/junk values in string when reading textfile

I'm trying to read in a .txt file (paragraph.txt as input) in C, and when I print the string it has garbage values on the end such as the paths to my visual studio, or junk data. This occurs 99% of the time with some exceptions. I have no idea why it is doing this? void readfile(char **buffer, char...
wrestlerdude
1

votes
1

answer
32

Views

Where is the following object property allocated?

I have the following code and I think that the arr property should be allocated on the heap, because the test object is allocated on the heap. But for some reason, the A destructor is being called, even though I do not call it explicitly. Is there explanation for this? CODE: class A { public: ~A(){...
Alex Lavriv
1

votes
0

answer
61

Views

How to set a strict memory limit to node js application?

I want to strictly limit allowed memory to my Node Js application. When I start an application with max_old_space_size=512 and start to fill some array with a lot of objects in a loop - application starts to consume more than 512 MB. It becomes even 1 GB. So if I understand correctly max_old_space_s...
LEQADA
1

votes
0

answer
88

Views

Array Slicing for recursive function in Java

I was working on a Java implementation of constructing a binary tree, given the pre/inorder traversal arrays. Code looks something like this (seems to work but I havent tested extensively) public static TreeNode buildTree(int[] inOrder, int[] preOrder) { if(inOrder.length
Robert Lemiesz
1

votes
1

answer
66

Views

PHP - Are there any real benefits to calling die() instead of echo?

I'm attempting to figure out if there are any benefits for memory usage if I call die(json_encode($array)); instead of just echoing the results and letting the script end. I imagine that it partly depends on the script, but I'm asking in the scenario where it works fine logically, but other conditio...
David Kamer
1

votes
0

answer
976

Views

PostgreSQL out of memory: Linux OOM killer

I am having issues with a large query, that I expect to rely on wrong configs of my postgresql.config. My setup is PostgreSQL 9.6 on Ubuntu 17.10 with 32GB RAM and 3TB HDD. The query is running pgr_dijkstraCost to create an OD-Matrix of ~10.000 points in a network of 25.000 links. Resulting table...
PaDe
1

votes
1

answer
147

Views

CoreMotion OperationQueue Issue on Apple Watch

Devices: iPhone 8, Apple Watch Series 3 I am currently working on a phone app + watch extension that streams CoreMotion data from all CoreMotion sensors using the standard APIs coupled with associated OperationQueues. I need to be able to stream all CoreMotion sensors in parallel, write the samples...
SDFire
1

votes
0

answer
332

Views

How do you dispose or free a file buffer in Node.js?

I have an object that contains a temporary file buffer: console.log(myObject) // output: { path: '/some/path', someBuffer: } After I'm done doing some processing on this buffer I want to release it. How exactly do you release or free a buffer from memory? Just set to null? myObject.someBuffer = nul...
Jake Wilson
1

votes
1

answer
424

Views

Does -XX:+UseSerialGC use main thread for GC

I have been reading (for example here and here) that with -XX:+UseSerialGC garbage collector only single thread is used for garbage collection. But it was not clear whether this 'single thread' is the main thread or a different single GC thread. So, I took a thread dump with and without -XX:+UseSeri...
pjj
1

votes
0

answer
96

Views

Best way to canvas drawing in Xamarin Android

I have a single Android View and i will draw set of canvas drawings (text drawing) in the same view. Now, I have a situation split those drawings in a separate views. Each text drawing will be in each view. So the number of child views will be the number of text. Due to this changes, Can anyone te...
VenkyDhana

View additional questions