Questions tagged [memory-management]
Process of dynamically allocating and freeing portions of physical memory in order to respond to program requests with, if possible, fairness and no starvation among the requesters.
26,475
questions
0
votes
0
answers
5
views
Describe the external fragmentation problem in contiguous memory allocation?
Describe the external fragmentation problem in contiguous memory allocation.
0
votes
1
answer
47
views
When I run my program I get the 'Segmentation fault 11' error. I'm not sure what in my code would cause this error
I understand that this error has to do with how much memory my program tries to use when I run it, but I'm new to C and I don't quite have a handle on memory management yet. If anyone wants to take ...
1
vote
2
answers
62
views
What happens in Ada when memory is deallocated?
I'm totally new to Ada, and I have to learn it for a course I'm having in school.
One of the exercises I've done asks for a procedure to swap pointers' adresses, then to change a pointer's address to ...
-2
votes
1
answer
35
views
How to know how much memory our object uses?
I know that int uses 32 bits. Long uses 64 bits and etc... But, how can we know how much memory our object uses? I have a class like this:
class Utils{
public String getName(Context context){
...
1
vote
2
answers
86
views
std::aligned_alloc() never returns a null pointer. How?
I am using std::aligned_alloc() in one of my projects to allocate aligned memory for optimized PCIe read/write.
When I read about aligned_alloc from here, it says:
Defined in header <stdlib.h>
...
0
votes
0
answers
14
views
Importance of the high order bits from Android memory allocations?
We’re using Visual Studio to develop our Android app and have recently moved from Microsoft’s Cross Platform environment to Google’s new “Android Game Development Extension” (AGDE). This change moved ...
0
votes
1
answer
69
views
Is rust vector continuously allocated?
I am new to Rust and I am investigating vector implementation. I tried to resize vector many times and check addresses of elements with following code:
fn main() {
let mut vector = Vec::new();
...
-2
votes
0
answers
49
views
How do I execute a part of code (e.g. a function) in a specific virtual memory address range in C?
Suppose I have a C code I have allocated a specific memory that I want to use to run a specific portion of the code (e.g. a function). There will be additional operations on the memory which I have ...
0
votes
1
answer
50
views
Constructing a shared_ptr in a for loop and move assignment
I'm trying to get my head around shared pointers at the moment and how they work. I would be really grateful for any advice you could give on the below.
Please could you advise on:
When to use std::...
0
votes
1
answer
24
views
Matplotlib memory leak when saving figure in a loop
I'm working on a big data set and i need to create and export images at each data point. I'm hitting the memory saturation at around the middle of the process. I applied some memory management tools ...
0
votes
1
answer
56
views
How is it determined which memory block to use in c/c++?
This is the code I wrote:
#include <iostream>
using namespace std;
int main() {
int x[3] = {30,31,32}, y[3] = {40,41,42}, z[3] = {50,51,52};
for (int i=0; i < 3; i++) {
cout ...
-1
votes
0
answers
62
views
How to find a location of a dll ( or a package)
I use windows 11 (the same problem was in win 10 as well). I use oracle VM as well. The operation system in VM is windows 7.
I installed my delphi 6 IDE in a folder shared between windows 11 and ...
0
votes
1
answer
54
views
Monitor not showing the right memory usage
I want to know how I can use the resource monitor, any kind, htop top, etc. to track the memory usage of a processes. Let's write a simple C program.
int main() {
while(1){}
return 0;
}
After ...
0
votes
0
answers
21
views
What is the memory usage of a reference to another object in java?
If for example, I had a linked list of nodes. Each having a field referencing the next node. How much memory does this reference (not the next object) take?
E.g if I have:
Class Node
nextNode node;
...
0
votes
1
answer
27
views
Memory usage of a char array with null values in Java
I'm attempting to calculate the memory usage of a trie search tree implementation in java. Each node contains a char array of size 52, with many of the indices being null values. I'm aware of the ...
0
votes
0
answers
35
views
What's the proper way to garbage collect?
I have some TypeScript code where a variable is of a certain type and can't be assigned null nor undefined. If I want to reset its value, so that the previous one can be garbage collected, would it ...
0
votes
0
answers
27
views
C++ simple and fast single-threaded allocator for small strings working in fixed preallocated memory region?
Looking for single-threaded allocator for small (1...400 bytes) strings, simple enough to be implemented in couple of days, working in preallocated large block of memory (say 1GiB). Must not be ...
-1
votes
0
answers
18
views
Best way to monitor local network storage and show a breakdown [closed]
Currently when I monitor space on my works local network, I would just use windirstat or wiztree and look at what is contained in the local network drives. Those software list the data type and how ...
0
votes
0
answers
11
views
A question about automatic data destruction
I am storing data as a series of strings collated into one string all separated by a token. To use the data, I mark the beginning and end of each data piece by the tokens then replace the tokens with ...
0
votes
2
answers
40
views
how does java collections saves an element (shallow or deep)
In the Java collections (array, LinkedList, Set), when an object is added, does it saves a copy of the reference or copy the entire object to the collection. And if I change the original object does ...
0
votes
2
answers
64
views
How do I search most common words in very big file (over 1 Gb) wit using 1 Kb or less memory?
I have very big text file, with dozens of millions of words, one word per line. I need to find top 10 most common words in that file. There is some restrictions: usage of only standard library and ...
-1
votes
0
answers
25
views
Performance wise, arer both theses lines of code the same in csharp for Unity?
Performance wise, arer both theses lines of code the same ?
pictureExample.sprite = Resources.Load<Sprite>("my_png");
pictureExample.sprite = Resources.Load<Sprite>("my_png&...
0
votes
0
answers
33
views
why am I getting segmentation fault instead of a garbage value output?
The following piece of code always gives garbage value as output. I am aware of the reasoning behind it as a dangling pointer is created which still points to the memory location which is freed and ...
-2
votes
0
answers
68
views
Replacing malloc() with my own implementation
I need a fast malloc() / free() replacement. There's mimalloc vom Microsoft Research which is actually on average the fastest malloc()- / free()-replacement. I've read the paper and the design is ...
1
vote
0
answers
36
views
Is there a way to Marshal a byte[] into a string without copying in C#?
I am in the process of building a sub-part of a native application, namely a Unity application that runs as a child of a different application written in a completely different language. Since we have ...
0
votes
1
answer
27
views
Rapid stack allocations vs accessing a single heap allocation
I'm having a situation where I have an array T[] which must be copied in an instant and sent over to a function accepting a ReadOnlySpan<T>. I found two solutions on this problem. However I'm ...
0
votes
1
answer
37
views
Can I call linux allocation API functions in C?
I want to allocate physical page frames using alloc_pages() in C. I have tried that in kernel module in it works fine. I want to make the code running in user space, just how we execute c code ...
2
votes
0
answers
22
views
How does the Python Memory Manager find existing objects? [duplicate]
I am fairly ok with Python, but recently I learned something that made me question everything I thought to be true in my life :D
So if I run this:
w1 = "word"
w2 = "word"
print(id(...
0
votes
0
answers
14
views
Number of entries require in the FAT table
Disk Capacity is 80 MB, block size is 512 bytes, and pointer size is 4 bytes.
What is the number of entries require in the FAT table?
What is the table size?
1
vote
2
answers
65
views
When would you ever want to keep a non-allocated object in memory?
This is a question in regards to non garbage-collected languages (C, C++, etc).
I've been told that one of the things that makes C++ faster than something like C# is the built-in garbage collection ...
-1
votes
1
answer
32
views
deallocate memory from deleted node in Linked list
I am having a problem with memory leaking when I remove a node and I would appreciate some with some sort of work arround so that I wont leak when I remove element.
BTW, if I just deallocate the ...
0
votes
1
answer
15
views
Private Data in VMMap is very large on some machines
I'm trying to debug a memory exhaustion issue for my native Win32 CPP app, so far i have found that on some machine when launched, app the memory usage is very high from the beginning and VMMap is ...
0
votes
1
answer
22
views
Do low-end embedded system have process isolation?
I am studying memory management. In particular, I am studying MMU and the mapping between the process logical space pages and the RAM frames.
My question is: what about low-end embedded systems? If I'...
0
votes
0
answers
43
views
leetcode 66)Plus One .Array memory allocation and BigInteger problem
I'm a beginner java programmer and having a doubt in Array memory allocation and BigInteger in the question 66)Plus One of leetCode. The question statement is as such:
Q)You are given a large integer ...
0
votes
0
answers
50
views
Does the g++ implementation of std::vector take available memory or total size into accounting when growing?
The commonly received wisdom about std::vector is that it doubles in size each time it needs to grow
beyond its capacity.
Though other commonly used grow factors include 1.5.
The amortised time ...
0
votes
0
answers
45
views
C++ Heap Corruption While Writing previously expanded array
I'm having an issue with Heap Corruption while writing any index of a previously expanded array. I have created an object with protected fields. Two of these fields are pointers holding arrays while a ...
0
votes
1
answer
47
views
Does C automatically free char * return if I use it for another function?
I have a function called combine that combines two strings, potentially with a / when I use it for file path combinations:
char* combine(const char* input1, const char* input2, int slash) {
char* ...
0
votes
3
answers
75
views
Storing numbers larger than Big integer C#
I am having a really hard time finding a way to store massive prime numbers in c#. I tried everything but nothing worked out for me. For example. How can I store this number.
...
0
votes
0
answers
13
views
What is the right memory allocations that can be given to multiple spark streaming jobs if it is being processed in a single EMR cluster (m5.xlarge)?
I have 12 spark streaming jobs and it receives a small size data at any time. These scripts has spark transformations and joins.
What is the right memory allocations can be given to these spark ...
0
votes
0
answers
26
views
Use of function kmem_cache_shrink() in slab allocation
While going through the slab allocation mechanism, I came across the following function.
int kmem_cache_shrink (struct kmem_cache *)
The description of this function can be found here.
The ...
0
votes
1
answer
49
views
Memory management and overflow in C
I always wonder why C manages the memory the way it does.
Take a look at the following codes:
int main(){
int x = 10000000000;
printf("%d", x);
}
Of course, overflow occurs and it ...
2
votes
1
answer
33
views
Freeing up memory from Matlab's Map
I've got a problem which requires me to keep track of a large amount of data in a hard to predict way. I do know a few rules however that allow me to determine when some data is not needed anymore.
I ...
0
votes
1
answer
25
views
How to use multiprocessing for sequential memory hungry tasks?
I am trying to execute a series of tasks that use a lot of memory because of the objects sizes. Basically here are the steps :
a = building_function()
saving_to_disk(a)
b = building_function(a)
...
0
votes
2
answers
48
views
How the CLR works in .NET that comparing all strings is efficient? [duplicate]
I've seen similar questions and answers but I couldn't find the one I'm thinking of.
How is this possible that CLR somehow knows which string is the same and which is not and makes the same object if ...
1
vote
2
answers
45
views
How to avoid excessive ram consumption using pathos
This is a rough example of how I leverage multiprocessing with pathos:
from pathos.multiprocessing import ProcessingPool
pool = ProcessingPool(10)
results = pool.map(func, args)
Each func's run can ...
0
votes
0
answers
29
views
Best way to store a huge matrix of ~10 billion elements
I'm doing an image based recommendation algorithm where I compute similarity scores between each pair of images and store them in a symmetric matrix. In total I've got 101551 number of images. First I ...
0
votes
0
answers
16
views
Why a tensor object gets a new memory location after repeating the already executed operation?
I'm performing a simple addition operation using two tensors.
In the above screenshots, it has been shown that even after performing the same operation twice different memory locations have been ...
0
votes
0
answers
23
views
Class pointer not initialized, but can still accesses class member function [duplicate]
I am curious to know the below scenario. I, think, know the explanation to this but want to know if my thought is correct in wider forum.
I tested on both g++ and clang++ compiler, and the result is ...
0
votes
0
answers
7
views
Can't create share memory on Center OS 7 , *shm return nothing
I am not sure Why *shm give me nothing ?
printf("Shmget() successful %d\n",shmid);
if((shm = shmat(shmid, NULL,0)) == (char*)-1){
perror("shmat");
}
printf("vlue of shm is: %...
-1
votes
0
answers
24
views
shm_ctl() equivalent on Linux?
Link to shm_ctl() manual
This API (which intends to be declared on sys/mman.h) allows any (privileged) user-space process to map a POSIX shared memory (shm_fd) object to specific physical address ...