Skip to main content

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.

memory-management
Filter by
Sorted by
Tagged with
-1 votes
0 answers
68 views

Copy constructor and creation of temporary object C++

Let me use as example a vector object but it applies to any object. Is it safe to create an object as MyVector xyz(std::vector<double>(10)); assuming that there is a constructor which take as ...
Albert's user avatar
  • 1
0 votes
0 answers
5 views

NVIDIA cufft Memory free-up

When I loop through the following code, the GPU memory continues to increase #include <iostream> #include <cuda_runtime.h> #include "device_launch_parameters.h" #include <...
潘光健's user avatar
-1 votes
0 answers
14 views

How to traverse VMA in Linux 6.6 version?

In the old version of Linux, we can traverse VMA like that : static void walk_vma_range(struct mm_struct *mm, u32 *nr_vma, u32 *nr_pages) { struct vm_area_struct *vma = mm->mmap; u32 i = 0; ...
Askemi Wang's user avatar
0 votes
0 answers
37 views

Do processes share the read-only sections of common dynamically loaded libraries?

I would like to verify how the memory consumption works when I have two different executables that depend on the same dynamically loaded library and the library has both "state" (i.e., ...
A.G's user avatar
  • 1
0 votes
0 answers
22 views

getting aligned pointer inside storage to place object

I have a storage in a form of an array of bytes. On the stack // storage on the stack, no requirement on alignment unsigned char storage[N]; Or on the heap // storage on the heap, no requirement on ...
Oersted's user avatar
  • 1,649
0 votes
0 answers
28 views

Getting heap storage with proper alignment in C++ for overaligned type

In some use case, you'll need to allocate storage before creating objects inside this storage. Then in order to create these objects, you may need to use placement new: T *pobj = new(pstorage); yet ...
Oersted's user avatar
  • 1,649
-1 votes
1 answer
50 views

Getting heap storage with proper alignment in C++ for non-overaligned type

In some use case, you'll need to allocate storage before creating objects inside this storage. Then in order to create these objects, you may need to use placement new: T *pobj = new(pstorage); yet ...
Oersted's user avatar
  • 1,649
0 votes
0 answers
17 views

When using `matplotlib.animation` and 'LineCollection`, how to reduce the size of the colors list

I am continuously plotting data using matplotlib.animation with multiple subplots that use a lot of segments. The issue I am running into is that size of the colors list is quite large ['Blue','Blue',....
THATS MY QUANT MY QUANTITATIVE's user avatar
1 vote
2 answers
106 views

printf does not call my version of malloc

I overwritten malloc to use a static buffer with TLSF allocation. but then when I call printf, the regular malloc is called instead of my custom malloc. void *malloc(size_t size) __attribute__((weak));...
Catalin Demergian's user avatar
0 votes
0 answers
67 views

Getting storage with proper alignment in C++ [closed]

In some use case, you'll need to allocate storage before creating objects inside this storage (a typical one is managing your objects inside pre-allocated pools of memory). Then in order to create ...
Oersted's user avatar
  • 1,649
0 votes
1 answer
59 views

Why is using JsonSerializer.DeserializeAsyncEnumerable to deserialize a 1GB file resulting in 2GB+ memory allocation?

I need to deserialize a 1GB json file one element at a time in a streaming fashion and after doing some reading found JsonSerializer.DeserializeAsyncEnumerable to enable this while also keeping the ...
DeanOfHouseAkin's user avatar
0 votes
0 answers
19 views

possible compilation problems and strange behavior of the memory allocation in C

I have a program in C that gets a continued fractional representation. It works fine, but shows an unpredictable behavior for some test cases (one of them is hard coded in program). In one from five ...
nikmal's user avatar
  • 11
0 votes
0 answers
35 views

Can a kernel memory address indicate its type of allocation?

I'm troubleshooting some Linux kernel code, and it would be nice to know where the memory pointer allocation originated. Question: Are there Linux kernel macros available like ADDR_IS_STACK_ADDR(ptr) ...
KJ7LNW's user avatar
  • 1,781
0 votes
1 answer
61 views

When a user process swaps out a page, is the virtual address of the page in user space or kernel space?

I am a beginner in Linux and have always been confused about the difference between kernel space and user space. I am currently researching memory management and would like to know if the virtual ...
Mia8Cew's user avatar
2 votes
3 answers
92 views

Why does the Rust compiler drop unused variables in the reverse order they were declared?

In the Rust book an example is provided in chapter 15 section 3 to show when Rust runs the drop function on the variables c and d. struct CustomSmartPointer { data: String, } impl Drop for ...
Anthony Ruiz's user avatar
1 vote
0 answers
55 views

measuring peak memory usage of a very fast program on windows

I've got a program that runs in a very short time (less than a second), on windows, in a powershell terminal. How can I measure "easily" it's peak memory usage (I cannot see it in the ...
Oersted's user avatar
  • 1,649
1 vote
1 answer
77 views

issue erasing elements in a vector using C

I wanted to go "back to the basics" and try writing a C vector implementation. It is using void* to store the data and i try to mimic the C++ counter part a little bit. I am having ...
Raildex's user avatar
  • 4,418
-1 votes
0 answers
16 views

How to Calculate Entries and Memory Requirements for a 2-Level Page Table in a 32-bit CPU Architecture?

I'm trying to understand how to calculate the entries and memory requirements for a 2-level page table in a 32-bit CPU architecture with the following specifications: Each second-level page table has ...
1 8's user avatar
  • 1
0 votes
0 answers
64 views

std::vector not clearing memory or bad custom allocator? [duplicate]

I ma trying to write a memory tracking class, which will help me to track memory consumption. I created an std::vector with my custom allocator and noticed that vector does not free memory on std::...
Victor's user avatar
  • 35
0 votes
1 answer
41 views

Load multiple images from Photos folder causes Out of Memory Exception

I have a small application that wraps a website that processes pictures. I can not upload more than 5 pictures from my phone, the application crashes with error: java.lang.OutOfMemoryError: Failed to ...
Roman Kozulia's user avatar
0 votes
1 answer
89 views

Can I Prove Monotonicity of Allocations to the Rust Borrow Checker

I have the following code which does not compile: // TODO: Return Result, remove `.expect`s fn to_blender_subfile<'a>( filepath: &str, transform: Transform, visited_file_cache: &...
William Ryman's user avatar
-1 votes
0 answers
28 views

Unexpected string found in memory snapshot of NestJS App with Fastify Adapter – Is there a memory leak

Started looking at memory snapshots (from node --inspect) for leaks in nest.js application and saw the following After making a request to handler there is a string left in the strings section that ...
Green's user avatar
  • 1
1 vote
0 answers
50 views

Memory management while loading python in C#

I am calling python function in C#. It loads deep learning model in C# framework successfully. However, i wanna release memory when task is done (for example detection/inference) but i am facing ...
Sahadev Poudel's user avatar
2 votes
1 answer
45 views

np.ones(30011,30011) needs 7.2GB, but Task Manager shows 5.3GB

A 30,011x30,011 of 64-bit floats takes 7.2GB. There are many explanations for why one might see np.zeros([30011,30011]) take up (say) a miniscule 0.7MB. However, my Windows 2010 Task Manager also ...
user2153235's user avatar
  • 1,018
1 vote
0 answers
67 views

Winking Out with polymorphic memory resources: efficient resource release and objects lifetime

I'm trying to understand "winking out" technique through examples (as I couldn't find, yet, a clean explanation). My goal is to acquire non-UB techniques that can be efficient when releasing ...
Oersted's user avatar
  • 1,649
0 votes
0 answers
32 views

How to Implement a Memory-Efficient Custom Iterator for Large Files in Python?

I need to iterate over extremely large files (several gigabytes each) in Python without loading the entire file into memory. Specifically, I want to implement a custom iterator that reads and ...
safiqul islam's user avatar
-1 votes
1 answer
62 views

Why should we set -XX:InitialRAMPercentage and -XX:MaxRAMPercentage to the same value for cloud environment?

I've read multiple articles about best practices for setting the {Min/Max/Initial}RAMPercentage values for java applications in the cloud environment. The purpose of Min and Max RAM Percentage flags ...
ilja's user avatar
  • 379
1 vote
0 answers
24 views

How Can I Optimize Machine Translation Model Training to Overcome GPU Memory Overflow Issues?

I'm trying to train a fairly standard machine translation transformer model using PyTorch. It's based on the "Attention is All You Need" paper. When I ran it on my PC with standard ...
dsb's user avatar
  • 2,477
1 vote
0 answers
46 views

Is there a Linux memory API to insert a block in my address space?

Suppose I have a data structure, and wish a component to grow. There are two choices. Either I create a linked structure and connect new chunks of memory with pointers, or I can allocate a single ...
Dov's user avatar
  • 8,342
0 votes
2 answers
55 views

Java Memory usage returning negative numbers on IBMi machine

We wanted to evaluate java performance on IBMi machine and I am very to the IBMi world. I am running java program to perform database CRUD operations on IBMi machine to know the performance. To ...
Nitin Chemate's user avatar
0 votes
1 answer
63 views

Stroustrup's PPP Memory Management Stack Example

Notice this comment in the code: space for char[N] and data to keep track of what is allocated and what is not (e.g., a top-of-stack pointer) In my opinion, only a top-of-stack pointer isn't enough ...
a1mersnow's user avatar
0 votes
0 answers
40 views

mremap with MREMAP_NOMOVE always return MFAIL with errno 12

I encountered a problem that mremap always outputs errno 12, regardless of the supplied sizes #define CALL_MREMAP_NOMOVE 0 size_t size = ...; void *p = mmap((void *)(0), size, PROT_READ|PROT_WRITE, ...
mandesero's user avatar
2 votes
1 answer
103 views

Why does Go's escape analysis move a variable to the heap even when inlining is applied?

Given this: package main func main() { _ = f() } func f() *int { y := 2 res := y * 2 return &res } If you run: go build -gcflags '-m' To get the escape analysis, it says this: ....
thestephenstanton's user avatar
0 votes
0 answers
12 views

How faster is stack allocation compareed to heap allocation?

I am coming from Java and just recently dabbling into C, Zig, Rust etc and from what I have learnt, Stack allocation is faster than Heap allocation. I have seen code bases in Rust that tries as much ...
Finlay Weber's user avatar
  • 3,781
1 vote
0 answers
36 views

How can I profile CUDA code for memory management?

I recently got started on CUDA. I wrote CUDA code to primarily manage memory on my GPU and the associated shared memory. Is there a way to profile the code and how much memory gets allocated/freed? As ...
emely_pi's user avatar
  • 629
0 votes
0 answers
82 views

DLLs, Classes & Memory Management

So this is more of a general question at this point, I don't have code written yet. But when you are writing code for DLLs in C++, is the burden of memory management on the DLL or on the user ? My ...
Joe Nestor's user avatar
0 votes
1 answer
78 views

Is there something like a pointer for numpy arrays?

I have an nxN numpy array where N is around 500_000. Depending on the use case of the program, n can be 1 or, e.g., 1000. I'd like to avoid flooding my code with if clauses on the shape of the array ...
aim137's user avatar
  • 1
0 votes
1 answer
91 views

C++ free() invalid pointer in a pool implementation

I'm reading and learning Stroustrup's "programming principles and practice using c++" book. And in chapter 25 about embedding system programming, to void memory fragmentation, the book ...
a1mersnow's user avatar
0 votes
0 answers
12 views

File-backed mmap in /var/run not showing in pmap output

I have created a file-backed mmap where the file is located in the /var/run/ folder. However, when I check the output of the pmap command for the running process, the file-backed entry is not visible. ...
anshkun's user avatar
  • 115
2 votes
0 answers
32 views

Why do we have a non-zero value for PSS in case of statically compiled binary

I read about PSS (Proportional Set Size), it's the number of non-shared pages used by the application and even distribution of the shared pages. I thought it's for shared libraries. To verify i wrote ...
md.jamal's user avatar
  • 4,407
1 vote
1 answer
83 views

C Can I use data that I freed just after freeing it

I have a linked list node I want to code a function that frees node. But order to do that I have to update next variable of previous node. Can I access to previous_node->next (previous_node->...
Egemen Yalın's user avatar
0 votes
0 answers
16 views

How to check PSS memory usage for a systemservice in Android

To get the PSS memory usage 'top' or 'dumpsys meminfo' does not work for an individual system service (eg com.android.server.wifi.WifiService) in Android that I am aware of. Is there a command or way ...
smshahriar's user avatar
0 votes
0 answers
25 views

torch.cat on torch.expand tensors

Consider the code below. I am creating two tensors using torch.expand, and they are using little memory 0.67GB. But when I use torch.cat to concatenate them, a whole lot more memory is used 7.3GB. Is ...
NNN's user avatar
  • 573
0 votes
0 answers
38 views

zephyr stm32 project: how to modify compiler/linker flags for build?

I am new to zephyr. Inherited a project whose target is an STM32H747I-DISCO Devkit. I am trying to determine how to modify the compiler/linker flags used during the build. The build is using west/...
peinal's user avatar
  • 121
0 votes
0 answers
28 views

What is the use of __pycache__ bytecode version of my file when the file itself is deleted?

I am playing around with import mechanism. Here's what happened: dir/b.py -> Prints "hello" dir/a.py --> Imports b.py For the first time, when I imported b (from a.py), a directory ...
Devarapalli Vamsi's user avatar
0 votes
2 answers
62 views

Web-scraping in R using while loops Error in open.connection(x, "rb") : HTTP error 429 when webpage exists

I've created a loop to scrape NBA regular season data. My loop cycles through all the regular season months over a set of years. My code keeps returning the error "Error in open.connection(x, &...
Omar123456789's user avatar
0 votes
1 answer
49 views

Memory usage too high when working with large JS ArrayBuffers

I'm writing some browser code with a lot of large ArrayBuffers. I noticed the memory consumption is unexpectedly large and I'm not sure why that is. I've never worked with ArrayBuffers before and I ...
n-l-i's user avatar
  • 163
1 vote
0 answers
55 views

How to Remove an Instance from Heap Memory in Flutter Dart?

I'm working on a Flutter project and I'm trying to understand how to properly manage memory. Specifically, I want to know how I can remove an instance from heap memory in Dart. I understand that Dart ...
Tejaswini Dev's user avatar
1 vote
1 answer
46 views

Need help pinning go/c memory for ffi call

I am learning go and cgo and ffi, I have the header file below: #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdlib.h> typedef struct MyStruct3 { ...
masber's user avatar
  • 2,997
1 vote
0 answers
71 views

How to track even dynamic memory allocation for a certain class?

I understand I can provide a custom allocator for most of the standard containers. If I record memory allocations in this custom allocator, then I can keep track of memory allocations. For example, ...
calvin's user avatar
  • 2,685

1
2 3 4 5
552