Questions tagged [memory]
The memory tag has no usage guidance.
72
questions
-1
votes
1
answer
26
views
Pset 4 Filter (More) -- PLZ HELP
When I declare the array earlier, I end up with the wrong output. But when I declare it inside the loop, the final output is correct.
Plz tell me how to explain this.
The wrong one:
void edges(int ...
0
votes
1
answer
43
views
program is free of memory errors
Im about to finish pset4, currently on recover! Everything is ok at the first look, program compiles, however, there is a problem when I run check50. As you can see from the title, something is off ...
0
votes
1
answer
17
views
Memory Leaking During Code Development
While I was developing speller, I ran many load programs before I wrote the unload program. What happens to all of the memory that I allocated while I was developing load before unload got written. ...
0
votes
1
answer
26
views
check50 indicates that my code has memory errors but executing valgrind in terminal says my code has zero memory errors
what is the problem with my code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
typedef uint8_t BYTE;
int main(int argc, char *argv[])
{
//check for usage
if (...
0
votes
1
answer
26
views
Segfault while declaring 2d array in filter-more's edges function. Probably a lack of memory?
At the very start of the edges function i try to declare an array to hold the image with black borders (now the first comment), but as i've discovered using printfs, it causes a segfault. I searched ...
0
votes
1
answer
32
views
PSET 5 Speller Valgrind Memory
My code is functional according to check50 but I'm still leaking bad memory. Based on amount of memory lost, I'm guessing something to close up in LOAD, but could be UNLOAD as well. First thoughts are ...
0
votes
1
answer
39
views
PSET 4 Recover Valgrind Check
Valgrind indicates I have 49 memory blocks left to close. Otherwise, the code satisfies check50. I'm thinking I need to nest the fclose functions within the loop, but I can't get it right. Thoughts?
...
0
votes
1
answer
119
views
Memory leak in Recover (PSet4)
I'm working on Recover and it all works fine but I've got a memory leak I don't know how to get rid of. My code is this:
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
...
0
votes
0
answers
103
views
Pset5 Speller Memory Problem
I am having a memory issue with my program in speller. Check50 returns all green except for the last line which says
:( program is free of memory errors
expected "MISSPELLED WOR...", not &...
0
votes
1
answer
1k
views
Speller Error - free(): double free detected in tcache 2 Aborted (core dumped)
// Implements a dictionary's functionality
#include <ctype.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <string.h>
...
0
votes
1
answer
761
views
Program is free of memory errors, valgrind tests failed - pset5 speller
I'm am getting this error - program is free of memory errors, valgrind tests failed; see log for more information.
I have tried so many things but I keep getting more errors. Here is my code:
// ...
0
votes
1
answer
72
views
pset5 speller memory errors with valgrind
i've been working in pset5 and cannot make it work. I've read some similar questions and made some improvements to my code, but still can't figure what is wrong. Any tips are welcomed!
Here is my code:...
0
votes
2
answers
199
views
Lab 4 problems when the audio is clearly altered
Source file:
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
// Number of bytes in .wav header
const int HEADER_SIZE = 44;
int main(int argc, char *argv[])
{
// ...
1
vote
1
answer
28
views
Pointers Memory Allocation
Here I have a user-defined structure "person" that stores two pointers one for the name and one for the phone number.
I create an array people of length 2 of type person.
Each of the ...
0
votes
1
answer
25
views
Filter - Structures & Headers
The problem statement states that BMP files have a particular header with: (1) BITMAPFILEHEADER 14 bytes long and (2) BITMAPINFOHEADER 40 bytes long.
bmp.h (provided) includes the definitions of the ...
0
votes
1
answer
76
views
Pset4 - Memory/reflection problem
So I've been on this reflection in pset4's memory problem for well over an hour and I can't seem to get the first column of height to reflect. Only the first column too, everything else reflects.
here'...
0
votes
1
answer
116
views
PSET4 Blur not passing Check50
My code seems to work (when visually inspecting output files), but Check50 does not pass it. I'm struggling to understand what is causing this issue despite having repeatedly read over the code and ...
1
vote
2
answers
112
views
PSET 5 SPELLER - Passing Valgrind but not Check50
I am very close to solving this, my code is returning 0 errors from Valgrind when I run that on its own, but its not passing the memory errors parameter in check50, so I'm very confused. Any help ...
0
votes
1
answer
25
views
Why is the reference variable for dynamically allocated memory lower on the stack?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
int n = 5;
char str1[n];
char *str2;
char str3[] = "World!";
// ...
1
vote
2
answers
851
views
Why Doesn't fwrite overwrite previously copied data?
I'm beginning to wrap my head around the week 4 problem set, and I'm confused about how the fread and fwrite functions work.
As I understand it, fread tells the computer to copy data into RAM, and ...
0
votes
1
answer
30
views
dynamically allocated memory for a node is changed without any dereferencing?
I am in week 5(data structures) and I tried to make a simple binary search tree.
then I tried to create a function for getting around on this tree!
this is a part of get_around function :
printf(&...
0
votes
1
answer
23
views
pointers and addresses
int m=10;
int *ab=&m;
printf("address of *ab:%p\n",&*ab);
printf("adress of ab:%p\n",&ab);
output:
address of *ab:0x7ffd85fddefc
adress of ab:0x7ffd85fddf00
i ...
0
votes
1
answer
268
views
code is free(): invalid pointer and Aborted, and I don't understand why
at first it worked. But i make style and add more coment and it was broken.
It makes all images but in the end:
free(): invalid pointer
Aborted
and i don't understand why. I rewrite code and all work....
0
votes
1
answer
52
views
My program is not free of memory errors Speller Pset 5. Can anyone help?
I am working in Speller of PSET5. My program compiles and only has one problem
:( program is free of memory errors
valgrind tests failed; rerun with --log for more information.
The rest of the ...
0
votes
1
answer
24
views
i don't know what is wrong when i run the program the output is all zeros
void blur(int height, int width, RGBTRIPLE image[height][width])
{
double red_sum ;
double green_sum ;
double blue_sum ;
double counter;
RGBTRIPLE new_image[height][width];
...
0
votes
1
answer
31
views
PSET 4 Recover - Copy-Pasting 1 Line from 1 Place to Another Causes Huge Error
This Code Below Worked Fine, I got Passed!!
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
typedef uint8_t BYTE;
int main(int argc, char *...
0
votes
1
answer
130
views
"File size limit exceeded" in Recover - how does file writing work?
I've been quite frustrated by trying to make progress in Recover. When I run my code, I am unable to make even the first JPEG file as the program continues running until the file size is exceeded. I ...
0
votes
2
answers
170
views
Pset5 Memory leak in unload()
I've been working on speller for about two weeks now and I've finally got the programm to work, but valgrind cam up with a few memory errors. I've managed to solve most of them on my own, but the leak ...
0
votes
2
answers
102
views
Memory issue (Valgrind "Still reachable")
My code seems to pass all the Check50 tests except the one for memory as valgrind returns a "still reachable" error. Not sure what needs to be done, any help will be appreciated. Thanks!
My Code
#...
0
votes
1
answer
62
views
Pset5 Valgrind Error: Reachable Memory
I've been on the speller problem for a while and I don't understand where i'm going wrong. Any help would be much appreciated. I'm getting the following error from valgrind when i run it alongside --...
0
votes
2
answers
147
views
Speller, pset5. Help fix memory loss. How to fclose properly? How to close char *index = malloc(46)?
I have a problem here, if I fclose(dict_source) (comment where I place it) all code stop working (code stop find misspelled words), also if I try free(index) it's return free(): invalid pointer. Other ...
0
votes
1
answer
26
views
valgrind return memory leaking even after free()
This is a code that I have written based on 2013 Section question.
I put free at the getAge() function but it is still returning error after running valgrind through it. I really dont know why. Any ...
0
votes
0
answers
1k
views
"Still reachable" in Valgrind
I have noticed on a few programs that, while none of them have any memory leaks, flag a "still reachable" message when run via valgrind.
Does "still reachable" simply mean that there are pointers in ...
0
votes
2
answers
75
views
Intuition for what is statically allocated memory vs dynamically allocated memory
So I'm just finishing Lecture 3, and even after research, I can't get a visceral handle on the difference between the two. Yes, I know that one is in stored in the heap, and the other in the stack, ...
0
votes
1
answer
138
views
Problem Set 4 Valgrind
I tried to implement Speller, but check 50 returns:
:( program is free of memory errors
valgrind tests failed; rerun check50 with --log added to end of command for more information.
When I run ...
0
votes
1
answer
457
views
Speller (pset 4 2019) - Can't fix memory leak in hashtable
I've been working on speller, and all my code does the job fine but I can't get rid of the memory leak valgrind is giving me.
It seems to be something to do with my load function. I think it's my ...
0
votes
1
answer
636
views
pset5 speller program is free of memory errors
I have search around alot of places and even looked at others code but I dont find my code is that much different.
I keep getting program is free of memory errors if I check with cs50.
I can run my ...
0
votes
1
answer
46
views
Pset5 - Memory leaks - conditional jumps?
My code goes through check50 however it fails due to valgrind test failures. I have looked at the lines the log errors refer to with no avail. What steps should I take to fix this?
checking that ...
0
votes
1
answer
407
views
Pset5 speller: how can I navigate through the Trie and free the nodes?
so I am stuck on this PSET5 speller for a quite while now, trying different approaches, looking at available information in CS50, shorts, pset problem explanation and I couldn't get to free all the ...
2
votes
2
answers
517
views
pset5 speller how to only use 7.4 kb memory?
I found in the Big Board (Spring 2018) that some people only used 7.4 KB memory (as highlighted), while the dictionary contains 140k words. I don't understand how that's possible.
0
votes
1
answer
35
views
Errors from context when running trie dictionary from pset5 speller through valgrind
I've managed to implement a trie data structure for speller, and it seems like there are no memory leaks, but when I run valgrind -v ./speller texts/lalaland.txt I get quite a lot of errors from ...
0
votes
1
answer
34
views
Pset4 - Array declaration- Heap
In shorts of Pset4 it was mentioned, that pointers are created in heap. Does it mean, that all arrays are stored in heap?
0
votes
1
answer
147
views
i don`t know what is wrong with my unload function?
enter code here /**
* Implements a dictionary's functionality.
*/
#include <stdbool.h>
#include<cs50.h>
#include <strings.h>
#include <stdio.h>
#include <...
2
votes
1
answer
342
views
Pset5 Speller Valgrind error
I got Pset5 Speller to work correctly but I am getting a Valgrind error as follows 568 bytes in 1 blocks are still reachable in loss record 1 of 1: (file: dictionary.c, line: 108) for all the words. ...
0
votes
1
answer
124
views
Memory leakage PSET 5
I've successfully implemented the dictionary and it fully works. When I run valgrind I get 2 nodes (224 bytes each) that are leaking. I really don't know how to fix this. Can someone help?
==1316== ...
0
votes
1
answer
79
views
pset 4 recover related question
In pset 4 we were suppose to recover images deleted from a camera memory card by means of reading card.raw and writing the jpeg data when a signature was found. Now suppose I want to recover data ...
0
votes
1
answer
82
views
Memory address in 64 bit OS
How long is the memory address of a single byte of 8 bytes allocated to pointer variable in a 64bit OS?
0
votes
1
answer
61
views
Writing a word puzzle solver and having a problem with freeing heap memory. Would really appreciate some help!
I am having some trouble with heap memory. I am writing some code to solve word puzzles - (from a game called Countdown here in the UK). The game is that you are given 9 letters and the goal is to ...
1
vote
1
answer
73
views
GetString() & Dynamic Memory Allocation
I observed in a walkthrough video in Week 4 (structs-0, I believe) David mentions that any variable created with GetString() should be free()d after its usage, due to the fact that, I vaguely quote ...
0
votes
2
answers
985
views
(pset5) valgrind - 1 block not freed
I've grinding away at this one problem for a couple of days now, and can't quite work out what's going wrong. My code passes check50. The output is fine. I'm relatively happy with how quickly it runs.
...