27,713 questions
Advice
2
votes
11
replies
389
views
I can't understand structure padding in C/C++
I watched a few tutorials on YouTube. They said to assume a 32-bit architecture and then said "a single CPU cycle can only access a word (equals the CPU's native size i.e 4 bytes) at a time from ...
0
votes
1
answer
35
views
HarfBuzz + FreeType on bare-metal: GSUB shaping causes hard fault
I’m trying to use HarfBuzz 8.3.0 with FreeType 2.13.2 and lvgl on NXP i.MX RT1064 with bare-metal and I'm encountering hard faults during Indic (GSUB) shaping [which you can see in the image]. I ...
Advice
1
vote
6
replies
137
views
How do I hint CPU to move data to a higher/lower cache level without flushing it beforehand
I''m writing a cache-friendly program with a lot of random read-writes and let's say I use a _mm_prefetch _MM_HINT_T0 intrinsic to load some data into L1 cache. Then I wanna prefetch another things to ...
Advice
0
votes
3
replies
104
views
Fortran: (or other languages) how to handle a linked list with allocatables instead of pointers?
(UPDATE: after various suggestions, some solutions were added at the end. It does seem to be possible to avoid pointers altogether, but it still is not completely ideal...)
In the question Can I ...
0
votes
0
answers
117
views
In Kotlin, Is there a way to hold weak reference to a function?
I realized that Kotlin is missing a built-in event mechanism similar to what we have in C#.
So I tried to implement my own and ran into a problem that can easily lead to memory leaks.
My original idea ...
1
vote
0
answers
83
views
Realm Database Operations Causing UI Hangs and Scroll Lag During Extensive Read/Write (iOS 16, SwiftUI)
I have severe UI hang issues whenever my sync worker is running. The app experiences:
Screen navigation freezes
Scroll lag and stuttering
Unresponsive UI during data synchronization
The root cause is ...
0
votes
1
answer
124
views
Why does heavy object cloning degrade JS performance even when using structuredClone compared to manual optimization? [closed]
In a high-performance Node.js service, I noticed that structuredClone() introduces unexpected latency spikes when cloning large nested objects (30–50 KB each). Even switching to manual cloning ...
2
votes
2
answers
109
views
Can you construct a NULL-terminated GPtrArray that doesn't have an element_free_func?
I'm writing some C code where I want to have a NULL-terminated GPtrArray containing static strings. Typically, I would use g_ptr_array_new_null_terminated () to construct a NULL-terminated GPtrArray, ...
Advice
0
votes
2
replies
92
views
What prevents Javascript memory leaks in software applications?
I was thinking back to WinJS or WinUI with Windows Universal Applications (WUA) from about 10 years ago. I am wondering how it compiled and avoided typical architecture errors. If there is no memory ...
0
votes
1
answer
241
views
Identifying a failed null check
I am working on a function that must read one line at a time from a file, give the file descriptor of said file as input.
Here is my get_next_line function, and helper functions on top of it
# include ...
1
vote
0
answers
61
views
Reassigning a Matlab pointer in a loop without a memory leak
We are using Matlab to communicate with a C++ library, and are struggling with memory management.
We create a libpointer pointing to an array, and then try to update its value in a loop. I don't think ...
2
votes
2
answers
92
views
mallopt(M_PERTURB) does not perturb the memory on free
I am trying to catch memory-related bugs such as use-after-free by mallopt(M_PERTURB, <value>).
According to the doc, the memory will be initialized to value when it has been released by free.
...
Advice
3
votes
4
replies
187
views
What happens in memory after return?
public class Test{
static int add (int m, int n){
return m+n;
}
public static void main (String[] args){
int a=1;
int b=2;
int c= add(a,b);
}
}
...
0
votes
1
answer
94
views
Paging in x86: what exactly is divided into pages, and why does the linear address behave differently depending on paging?
I'm trying to fully understand how paging works in the x86 architecture when segmentation is also enabled.
I have a couple of questions:
Does paging divide the logical memory (the selector + offset ...
8
votes
0
answers
217
views
How to safely resize a std::vector and detect allocation failure when exceptions are disabled (ESPHome / embedded C++)
I'm working in an ESPHome / embedded C++ environment, where exceptions are disabled, so std::vector::resize() won't throw std::bad_alloc on allocation failure.
I need to resize a std::vector to match ...