Skip to main content

Questions tagged [memory]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
6 views

p is assigned a memory first but when create family is called again, isnt the last memory lost as now p points at a new chunk of memory?

person *p = malloc(sizeof(person)); // If there are still generations left to create if (generations > 1) { // Create two new parents for current person by recursively calling create_family ...
Omer Matin's user avatar
-1 votes
1 answer
47 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 ...
xyj's user avatar
  • 1
0 votes
1 answer
91 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 ...
liza's user avatar
  • 13
0 votes
1 answer
29 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. ...
Zach's user avatar
  • 1
0 votes
1 answer
33 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 (...
Michael's user avatar
0 votes
1 answer
57 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 ...
Decowry's user avatar
0 votes
1 answer
36 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 ...
mcweebus's user avatar
0 votes
1 answer
57 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? ...
mcweebus's user avatar
0 votes
1 answer
152 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> ...
software_dev_wannabe's user avatar
0 votes
0 answers
129 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 &...
sage7major16's user avatar
0 votes
1 answer
2k 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> ...
incog 's user avatar
0 votes
1 answer
158 views

CS50 pset5 Speller: double free or corruption

I get double free or corruption (fasttop)\n Aborted when I run my code. Somehow, only small dictionary can handle up to around 50 words perfectly but sometimes it can only handle 10 words; other than ...
mossburger55's user avatar
0 votes
1 answer
989 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: // ...
aw_codes's user avatar
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:...
nico_so's user avatar
0 votes
2 answers
230 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[]) { // ...
shimurai's user avatar
1 vote
1 answer
30 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 ...
LorenzoPeve's user avatar
0 votes
1 answer
26 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 ...
LorenzoPeve's user avatar
0 votes
1 answer
102 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'...
Richard Cui's user avatar
0 votes
1 answer
127 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 ...
braninpodolski's user avatar
1 vote
2 answers
117 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 ...
Seamus McGill's user avatar
0 votes
1 answer
27 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!"; // ...
Matt Shirvan's user avatar
1 vote
2 answers
1k 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 ...
WhatEvenIsCoding's user avatar
0 votes
1 answer
38 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(&...
logan's user avatar
  • 1
0 votes
1 answer
25 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 ...
Praneeth Kumar's user avatar
0 votes
1 answer
334 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....
Вячеслав Порядин's user avatar
0 votes
1 answer
53 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 ...
Nicolas Sabate's user avatar
0 votes
1 answer
26 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]; ...
Muhammed's user avatar
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 *...
user avatar
0 votes
1 answer
137 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 ...
beanbanx's user avatar
0 votes
2 answers
173 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 ...
Renée's user avatar
  • 19
0 votes
2 answers
110 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 #...
atr1's user avatar
  • 3
0 votes
1 answer
63 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 --...
Kalahari's user avatar
0 votes
2 answers
153 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 ...
Oleg Kobeliatskyi's user avatar
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 ...
junyuanjyjy's user avatar
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 ...
Gabriel Saul's user avatar
0 votes
2 answers
90 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, ...
Tanishq Kumar's user avatar
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 ...
Eliqwa's user avatar
  • 3
0 votes
1 answer
458 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 ...
user23081's user avatar
0 votes
1 answer
645 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 ...
Shin's user avatar
  • 15
0 votes
1 answer
47 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 ...
benrob1996's user avatar
0 votes
1 answer
419 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 ...
Gintas's user avatar
  • 107
2 votes
2 answers
519 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.
David H. J.'s user avatar
0 votes
1 answer
37 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 ...
doctopus's user avatar
  • 119
0 votes
1 answer
36 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?
LCK's user avatar
  • 15
0 votes
1 answer
149 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 <...
mohamed ahmed's user avatar
2 votes
1 answer
349 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. ...
noob's user avatar
  • 23
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== ...
Ivan Pedroso's user avatar
0 votes
1 answer
81 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 ...
A.Emad's user avatar
  • 176
0 votes
1 answer
97 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?
qwerty's user avatar
  • 64
0 votes
1 answer
62 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 ...
Jeremy Tung's user avatar