Memory Questions
Ad
Memory leak in recursive function in C
My little c program is iterating through the working directory's contents and there is no problem with that, but i checked it with valgrind and
Why does the sizeof operator in C gives different output in case of NOT operation?
I am new to programming, and was introduced with the sizeof operator of c. playing with it, i found the following interesting
Dynamically allocate an object, will the members that aren't ptrs (not dynamically allocated) in the struct be in the stack instead of the heap?
Say i have this struct: typedef struct list_object list; struct list_object { char* name; struct stat stats; };
how does malloc produce an element of a list in C?
This is a code from my programming with c course that prints a list, using adt structs. typedef struct list{ int data;
Create an array of unknown strings - Undefined behaviour
In what way is the following code faulty or undefined behaviour? i suggested
How to create an array of strings of unknown size?
I'm trying to understand how can i create a c program that declares an "array of strings" whose size is unknown at the time of
Swift table view with videos playing in table view cells, memory leak
I am making an ios app that can be compared to instagram with a feed of videos (no images). i have a table showing custom table view cells, each
Is there a better way to mask bits?
So i am trying to split memory addresses into their page number and offset components by masking the hex numbers. but to cover a decent variety of
Valgrind leak of memory in a function that concatenates strings
I using valgrind to find a leak of memory. i wrote a function "prefix_to_string" to concatenate any two strings, but when i use the
What is happening with the pointer in this C code?
Question-> #include<stdio.h> int main() { int a,*b,**c,***d; int x;
Ad
How to dynamically increase size of any structure objects during runtime?
I am a bit of a beginner in c language. i was trying out a task of dynamically reallocating memory as the input comes through(although for this
C Coding :: Writing Structs into a Chunk of Memory
I'm working on a project which must be coded in standard c. (not c++.) a while ago, i wrote the below program, writes the contents of different
How to stop input overflowing via stdin
My program is supposed to accept input via stdin and store the string into an array of size size. my problem occurs when i
Accessing a pointer to a struct results in a memory read violation
Recently i've been programming a lot in c, due to an influx of free time. as c (in my opinion) is a very difficult language to pick up and learn,
Why does free() cause an error in my code when it's there, but everything runs well when it is not there?
My program takes an arbitrary number of words at runtime and stores them in a dynamically-sized array of words. currently, my program runs
Use of pointers in dynamic memory allocation
Can someone explain to me why when i dynamic allocate memory with calloc or malloc i declare: int *arr
Is it safe to call realloc() on the pointer you pass into function itself?
Note: i am not 100% confident with memory allocation and how it works, but i understand it for the most part. when i see
Determining whether the stack grows downwards by computing the difference in addresses of local variables
Would computing the difference in the addresses of the stack variables not be the way to determine whether the stack grows upwards or
C Allocating Memory in Loop: Error munmap_chunk(): invalid pointer
I wrote a little test code that allocates memory and just seeing the result on valgrind when i free the pnumber variable. #include
Free() after using malloc in linked list
I know that each time i use malloc or calloc i have also to free that memory, but in this specific case i can't understand when free the memory
__builtin_object_size always returns -1
I understood, that __builtin_object_size should give information about the size of an object, if it can be determined at compile time
Ad
what does something like 0400:0130h mean for register location?
I've been trying to develop with devkitarm and only notable guide is coranac's tonc, everything's fine but i can't get what it means when some
Copy n words in a single string using strcat
How can i copy n different words in a single string using strcat? this is my code but doesn't work. the size of the single words is 40.
Dynamically allocate an array of strings
How can i fix this code in a way that it prints the words in the array? moreover this is the right way to dynamically allocate memory for
Is it possible to define any size array in a C function call?
Does the below code is safe to use? somehow i think this not right way to do. i know a better way is malloc(), realloc(). but i want to understand
Dynamic memory allocation for node in linked list
Why when i have to declare a pointer to a node (head) i also have to allocate memory with malloc or calloc for it? i saw
Allocate memory in a function, then use it outside
I want to allocate memory inside a function with malloc and then return the buffer. then i want to be able to strcpy a
how to free memory of char arrays after passing them to exec*() family of functions
I am writing mixed c++/c code and making use of exec* family of c functions. consider the following code: char **argv
What are for square brackets in an addressed-of pointer?
I've been searching for a while what are for square-brackets in an addressed-of pointer, but i continue without understanding it. here are the
Function cannot find failed memory allocation
Function int load(const char *filename, int ***ptr, enum save_format_t format) should load data from binary or text
cs50 speller "unload" memory leak
My cs50 speller function finally works, but when entering it into check50, it says there is a memory error with valgrind. here is my unload
How to fix realloc expected declaration specifiers or ‘...’ before ‘sizeof’ error?
I get the following error below after calling realloc void* realloc(sizeof(char)100); the error:
Ad
Function allocate and modify many (more than one) arrays in C
A c function can modify more than one variable by an illusion of pass-by-reference (a pass-by-value of address as explained by
Using %c in scanf and assigning the value to an int variable in C?
Int main() { int i= 0; printf("i value is %d\n",i); scanf("%c", &i); // i am giving an input of 255
Is this C program safe?
I am concerned about memory leaks in this program. specifically, the check_if_pal procedure increments the str pointer
Writing outside heap in mergesort
I have been implementing vanilla version of a merge sort in c. in a sorting section itself, which is a separate function, i created a temporary
Understanding results with valgrind
For the following code i have the following defintion: typedef struct string {char* data; int length;} string; if
Reading bits from the bin value
What is the order one has to read the bits from the bin value? having for e.g.
Dynamically allocating memory to an array and reading a large text file
I've had a look at some other similar questions and examples but i'm stumped. my goal is to open a very large text file (novel sized), allocate
Remote mmap syscall using ptrace (Linux, C)
I've been stuck with this problem for some days, and still haven't manage to fix it. basically, i want to do a remote syscall from an attacker
Do int return the memory location/address?
There is no code for this question at all..just a simple question... as strings return their memory location\address but do int do the same or
Should I use both if and else conditions when dynamically allocating memory in c?
Int main(){ int* index = (int*)malloc(n*sizeof(int)); if(index == null){ printf("memory not allocated.\n");
While loops and arrays causing very odd behaviour...maybe a memory mixup
I'm tired of this tom-foolery occurring during runtime , although i'm sure we all are, when our programs screw up at runtime in the most obscure
Ad
In this below C code related to pointers and its output, then why doesn't the value a[1] i.e 20 get stored at consecutive address de9?
In the below code , each location can hold 32 bit signed data. so, why doesn't the value
How use free() function in this case? using malloc() and realloc()
Can you tell me where i have to put the free() function for the array "arr" in this code? i tried to put free(arr) before the last
Running address of an application, followed by heap and stack expansions
I have an m.c: extern void a(char*); int main(int ac, char **av){ static char string [] = "hello ,
Simple cuda kernel add: Illegal memory after 2432 kernel calls
I build a simple cuda kernel that performs a sum on elements. each thread adds an input value to an output buffer. each thread calculates one
Is malloc dynamic memory allocation?
I was told by an instructor that p = (int*)malloc(5 * sizeof(int)) is not dynamic memory allocation and that
What does Valgrind mean when it says memory is "definitely lost"?
The following program: #include <stdlib.h> int main(void) { char *my_str = malloc(42 * sizeof(char)); return 0; }
Editing structure instance's member values inside single/multiple thread(s)
I am attempting to edit a structure's member value(s) within single/multiple threads on windows, consider the following example:
Why malloc doesn't allocate memory until I hit a certain threshold?
#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char *argv[]) { size_t sz =
Share scoped variable in OpenMP
I'm working with openmp and would like to share variable that's declared inside scoped block between threads. here's overall idea of what i'm
Embedded memory allocation and scope
If i want to create a structure initialization functions that return a pointer to the initialized structure members, will the allocated memory to
What's the fastest way to copy two adjacent bytes in C?
Ok so let's start with the most obvious solution: memcpy(ptr, (const char[]){'a', 'b'}, 2); there's quite an
Ad
Creating an object in shared memory inside a Shared Lib (so) in C++
Is it possible to share a single 'god' instance among everyone that links to this code, to be placed in a shared object? god* _god
Common memory optimization
What are the most common memory optimizations in csharp, dotnet 2.0. wanted to see if there common things that people may not be doing by default
Does the correct use of "volatile" still (always) result in a program with undefined interaction with that data?
Online examples of correct use of the volatile keyword
FLVPlayback component memory issues
My website is entirely flash based, it moves around a 3d model which was given to me as chunks of video that i've converted to flv files. i'm
When I'm accessing memory values in my microcontroller why is it pointing to the end of my data value?
I'm trying to get the value of at an address in memory in my microcontroller. the address is at 0x1fff7000 and that's the start of
C - Reading file and putting text into char pointer with dynamic memory allocation
I'm trying to read a basic shader line by line from an external file i wrote for a c program. in the file there are two shaders: vertex and
Can the Pagemap folder of processes in the Linux kernel be read(64bit per read) a finite number of times?
I'm trying to keep track of the number of writes per physical page in the file "proc/pid/pagemap".but the file is binary, and the size
Simple WPF sample causes uncontrolled memory growth
I have boiled down an issue i'm seeing in one of my applications to an incredibly simple reproduction sample. i need to know if there's something
Why does the array contain values which I did not specify?
I'm trying to make a program which crosses binary numbers. the problem is with the cross function. it accepts two binary sequences
Get OS-level system information
I'm currently building a java app that could end up being run on many different platforms, but primarily variants of solaris, linux and
Resolving valgrind "possibly lost" memory leak
I'm having trouble interpreting and debugging the valgrind output for a c program i just finished from an online course (nand2tetris) that is now
Ad
Is specifying more size than required when declaring an array a bad practice?
In c language, when we don't know the size of the data we're going to hold in the array. generally, we specify more size than required. does that
Using mmap with hint address is the address of a global variable and MAP_FIXED
I have 2 or more processes accessing to a shared memory. i want to create a global variable in each process and then mapping the address of this
Is there a single resource which explains windows memory thoroughly?
Seriously, i've trawled msdn and only got half answers - what do the columns on the task manager mean? why can't i calculate the vm usage by
What is the motivation behind this "pattern"?
I'm a bit confused when i see code such as: bigbox := &bigbox{} bigbox.bubblegumscount = 4 // correct...
Which is the fastest way of querying strings in python
Assume you have to query the prices of like 100 items (in the example i will query just 2) that are unique, which would be the fastest (measured
std::make_shared leads to undefined behavior, but new works
Consider the following example class: class foo { public: void* const arr_; foo() = delete; foo(const size_t size,
Some kind of task manager for JavaScript in Firefox 3?
Recently i have been having issues with firefox 3 on ubuntu hardy heron. i will click on a link and it will hang for a while. i don't
How can I find out how much of address space the application is consuming and report this to user?
I'm writing the memory manager for an application, as part of a team of twenty-odd coders. we're running out of memory quota and we need to be
How to achieve memory coalescing when iterating over non-square 2D arrays?
I'm struggling to figure out memory coalescence in cuda. in order evaluate the performance difference between coalesced and uncoalesced memory
Are class arguments stored after function execution?
I am brand new to c++ and trying to better how understand memory is allocated and stored in class methods. lets say i have the following code:
Can't fill dynamic array
I'm learning c++ now and i have some misunderstandings i've created 2d dynamic array, but i can't fill it i've got error in 44 line like: access
Ad
Where am I accessing illegal memory? realloc(): invalid next size
I'm making a shell simulator for an operating systems course homework. we were asked to add a "history" command that when typed, should
Are data members allocated in the same memory space as their objects in C++?
Say i've got a class like this: class test { int x; someclass s; } and i instantiate it like this:
How to compress data
I'm trying to compress data to improve the space complexity, but i'm not sure if i'm incorrectly compressing data or incorrectly measuring the
why malloc() changes char pointers own address
I want to write a function that can take a destination pointer to allocate memory and copy a source into it. if i try to allocate memory
How do I dynamically allocate a struct but not it's attributes?
I'm a programming noob. i want to allocate a struct but since the size of my attributes are already defined, how would i use malloc() in this
memory usage increases when scrolling in recyclerview
I'm using recyclerview to list around 120 layouts that include 1 imagebutton,1 textview and 1 button. the initial memory usage when i first launch
Should I use broadcast receiver inside a recycler view row to update download progress of that item?
I've a recycler view which does download list items. i can think of two ways to update the state of a row at nth pos - i can
How can I use H2 database with laravel?
I am currently in a project and we need for some reason use h2 database. i would like to do an api in this project and i want to use laravel,
Placement New Operator
#include<iostream> using namespace std; int main() { int buf[2]; int *p=new (buf) int(2); int *q=new (buf+1)
How to load images from memory to numpy using file system
I want to store my image directory in memory, then load the images into a numpy array. the normative way to load images that are
Segementation fault whilst trying to deep copy struct
I have this piece of code, where i have an array of constituencies and i wish to deep copy the whole array into a new array. now too me, it seems
Ad
How to free data malloc()'d inside a loop?
#include <stdio.h> #include <stdlib.h> typedef struct node { int data; struct node *next; } node; void
edit a string by removing characters without creating a new string, is it legit or not?
Edit: i think i've understood how this concept works, this is my code void delete_duplicate(char* str) { if (str == null) {
is static variables cause memory leak in android?
Is there is any chance of memory leak in static variable like in class public class date extends linearlayout{ private static
Will using Asynctask in another class or in a headless fragment still cause memory leak?
I have read that using asynctask as an inner class of an activity will cause memory leaks because it won’t let the activity get garbage
Wired Out of memory: Java heap space error with ffmpeg library
Well this is the error i get: out of memory: java heap space. please assign more memory to gradle in the project's
How can I save a file (in node.js) from memory to a specific location on the disk?
I'm trying to save a file to a specific location on the server disk (using multer), but this location name is related to data i
C code runs but nothing happens when i read from file
What i'm trying to do here is to read lines 3 to 32 and 35 to 44 from a csv file. when i read the lines, i use strtok to separate the values and
How might I store in a variable the string read by fgets() without leaking memory?
I want the following code to accomplish to store the content of the file it reads in a variable content without leaking memory:
How to access 2 dimensional Array Pointer in a typedef-struct over a function in c
I have problems with accessing the 2d array in a typedef from a other function over a pointer, even if i allocate the array in heap!
How do I make 400k requests 200 at a time?
I have a massive amount of requests and i need to run more or less 200 to 600 of said requests simultaneously, but no more than that amount. at
Close redis connection on google cloud function end
How do you close the connection to a redis memory store from a cloud function when the cloud function instance terminates? (i believe to close i
Ad
SharedPreferences for multiple activities using an extend class
I have an application with three activities. here is my activity lifecycle: activity1 -> activity2 -> activity3. all my activities are use
How to avoid memory leaks in RecyclerView ViewHolder?
I have a recyclerview with a header with a viewpager. since there is no way to make a viewpager flip views automatically, i've added a runnable
Ad
Blog Categories
Ad