Questions tagged [memory-leak]
The memory-leak tag has no usage guidance.
77
questions
2
votes
1
answer
222
views
Memory leak in Pset4
According to valgrind I have a memory leak in my version of resize.
Here's the valgrind output:
==22900== Memcheck, a memory error detector
==22900== Copyright (C) 2002-2013, and GNU GPL'd, by ...
2
votes
1
answer
326
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. ...
2
votes
1
answer
375
views
CS50 PSET5 Memory Leak (updated)
I had posted a question here two days ago regarding memory leak in problem set 5 and haven't had it resolved yet. Please refer to my question, available here: CS50 PSET5 Memory Leak (please note that ...
2
votes
1
answer
517
views
Memory leaks found in system programs
I used Valgrind to check for memory leaks in several system programs, including ls, gedit and Make. I discovered that these programs do have memory leaks. Is this a serious problem whenever I use ...
1
vote
1
answer
148
views
CS50 pset5 Memory Leak (trie structure)
So I've written the functions for pset5 using a trie and it seems to work fine. It gives the same number of misspelled words etc. as the cs50 one, but it seems that there are some memory leak problems....
1
vote
1
answer
747
views
Memory allocation: recommended practices
I'm rambling a little with hacker 2 (the passwords') and, in the meantime, gained some insight about pointers, mem-alloc, 'valgrind', etc... It's been a truly great, challenging experience.
But, ...
1
vote
1
answer
559
views
Pset5: strcasecmp doesn't return 0 when given the same string input
// Implements a dictionary's functionality
#include <stdbool.h>
#include <strings.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
...
1
vote
1
answer
145
views
Pset5 SPELLER, CHECK50 errors and memory leak
I've been strugling with this pset for nearly two weeks. Today I finally managed to make it work. When I test this program it works good with given files, but check50 says that it's not working ...
1
vote
1
answer
80
views
Valgrind memory leak, WORDS MISSPELLED: 1 pset5
Looks like your program leaked 1,120 bytes of memory. Did you forget to free memory that you allocated via malloc? Take
a closer look at line 48 of dictionary.c.
Its weard because i am freeing the ...
1
vote
1
answer
71
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 ...
1
vote
1
answer
767
views
Recursion Destroy Singly linked List, memory leak?
I'm working through some personal test code to make sure I understand how to work withs singly linked lists.
I'm basically going through the Week 5 Section video on singly linked lists and putting ...
1
vote
1
answer
1k
views
Why Am I Having a Memory Leak?
Considering this simple program,
// preprocessor directives
#include <cs50.h>
#include <stdio.h>
#include <stdlib.h>
// define a struct
typedef struct structure
{
string str;
}...
1
vote
2
answers
175
views
Pset5 - Code for dictionary.c works but valgrind returns memory leak
I chose to implement speller with a hash table and the code seems to be working fine and passes check50 except for a memory leak. I read other posts reporting similar issues and I think that the issue ...
0
votes
2
answers
137
views
Speller Valgrind Issues
I've been trying to finish up the speller pset, and while everything works well, I keep getting a memory leak. When I rerun check50 with --log, I get:
checking for valgrind errors...
56 bytes in 1 ...
0
votes
2
answers
73
views
Help In Solving Memory Leak For PSET5
I need to fix the memory leak error for me to complete pset5. When running my code, I get:
:) dictionary.c exists
:) speller compiles
:) handles most basic words properly
:) handles min length (1-char)...
0
votes
1
answer
189
views
CS50 pset5 program is free of memory errors valgrind tests failed;
I'm just minutes away from solving my problem in pset5. But I'm getting the following error from valgrind.
==12523== HEAP SUMMARY:
==12523== in use at exit: 0 bytes in 0 blocks
==12523== total ...
0
votes
2
answers
6k
views
speller valgrind "uninitialized error was created by heap allocation"
I'm running valgrind on my speller for a hashtable. One of the errors I get, I'm not sure I understand is
uninitialised value was created by a heap allocation
==3079== Uninitialised value was ...
0
votes
1
answer
34
views
How is my (custom) program leaking memory? I am preparing myself for pset5
I'm trying to understand how memory allocation and pointers work, since i find pset5 overwhelming.
I made a simple program that reads characters from an array, and let them be written into both a new ...
0
votes
1
answer
220
views
pset5 speller valgrind show leak in load function
my speller code works very well with all texts
but when i ran valgrind there was heap leak in load() specifically in new_node malloc
can you help me figure out why?
there is my code for load() and ...
0
votes
2
answers
102
views
pset5. Can't trace memory leak
Load function (with a trie data structure)
//DEBUG
unsigned int allocs = 0;
// define node and create root
typedef struct node
{
bool is_word;
struct node* children[27];
}
node;
node* root;
...
0
votes
2
answers
345
views
Pset5 Speller Memory Leak
I have a memory leak. Valgrind told me that I had over 10000000 errors.
So what is the problem? Someone told me there was no problem in my unload function, so here's my Load function.
bool load(...
0
votes
1
answer
145
views
Pset5 unload trie 244 bytes lost
So, I'm finishing up pset5 and I'm now just trying to make sure theres no memory leaks. Unfortunaly there are 244 bytes being lost and I'm not sure why they're being lost. This is my free code:
bool ...
0
votes
1
answer
1k
views
char* and read-only memory
Take a function that creates a char* and does something with it.
void print_hello_twice()
{
char* hello = "hello";
printf(hello);
printf(hello);
}
This is a silly pointles example, but I ...
0
votes
2
answers
280
views
Freeing temp node in unload pset5
------------------EDIT----------------
Everything is working fine, except for this one thing. My solution is identical to the staff solution, albeit quite a bit slower, but that's another topic. I ...
0
votes
1
answer
302
views
Problems with letters "a" and "I" misspellings
My program loads and checks correctly with small texts and the large dictionary. Although when I load large texts, for some reason calls misspelled for the letters "a" and 'I'.
I'm struggling with ...
0
votes
1
answer
191
views
pset 6 memory leaks
enter preformatted text hereSpeller works but valgrind says I'm having memory leaks:
52 bytes in 1 blocks are definitely lost in loss record 1 of 1
==1454== at 0x4029F6F: malloc (vg_replace_malloc....
0
votes
1
answer
11
views
Recover runs, but leaks 472 bytes in 1 block
The code for recover (pset4) works fine, and has passed check50, except for the last check - no memory leaks. Valgrind shoots back:
==5482== Memcheck, a memory error detector
==5482== Copyright (C) ...
0
votes
1
answer
34
views
PSET5 - Speller - Valgrind returns memory leak
After many trials, I am currently stuck in this Pset. The full code that I have is as follows:
// Implements a dictionary's functionality
#include <ctype.h>
#include <stdbool.h>
#include &...
0
votes
1
answer
36
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
1
answer
29
views
PSET5 Load function leaking memory
I'm having a problem with memory leak, when I use Valgrind it tells me that I have 512bytes of memory leaked, I know the problem is with load because of Valgrind and because my load functions is ...
0
votes
1
answer
388
views
Pset5 - Speller - memory leak?
My programme runs and I'm passing all the checks bar the last one.
When I run the check with --log I get this response:
:( program is free of memory errors
valgrind tests failed; rerun with --log ...
0
votes
1
answer
56
views
PSET5: memory leak in check function
bool check(const char *word)
{
unsigned int hash_index = hash(word);
node *trav = table[hash_index];
while (trav != NULL)
{
int len = strlen(trav->word);
char ...
0
votes
1
answer
138
views
Cannot understand why valgrind is giving error although check50 runs properly
In this problem, (filter), I'm receiving all green from check50. But when I ran valgrind for blurring I got the following error:
==4412== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al....
0
votes
1
answer
46
views
Confused with Memory Leak in pset5 Even Though the Problem is Fixed. What was wrong with my size function?
Thank you in advance for taking a look at my code.
I have been getting this error below:
==4734== 8,011,640 bytes in 143,065 blocks are indirectly lost in loss record 1 of 2
==4734== at ...
0
votes
2
answers
237
views
Unknown memory leak on "check function" - CS50 Speller
I have trying to decode the information gathered through valgrind with no success. I followed the hints given by valgrind trying too free the malloc'ed node *checker but to no avail. I've searched ...
0
votes
1
answer
131
views
PSET4 unload() don't work
I'm not sure if my unload() function worked properly. I tried to use Valgrind and it said memory leaked 8mb. I tried check50 and it said I have a memory leak.
Also, the time takes very long, it ...
0
votes
1
answer
327
views
56 Bytes of leaked memory in speller.c pset5
56 Byte memory leak - not sure where it is coming from. Valgrind points to the malloc'd space for nodnew in the load function - in my first version, I created the pointer nodenew and malloc'd the ...
0
votes
1
answer
13
views
How can I ensure I'm changing the reference, not a copy, in this C function?
I'm trying to assign a pointer to a pointer within a function. I've passed pointers in and I'm trying to make the change inside. It is not happening, however. The issue is regarding the insert ...
0
votes
1
answer
85
views
Pset5 Memory leak with trie scructure
after almost 2 month of working I am finishing the pset5 but...
I get memory leaks. valgrind plus help50 is giving me this:
Looks like you're trying to access 8 bytes of memory that isn't yours? ...
0
votes
1
answer
80
views
Why C doesn't check for memory leaks automatically?
If there is a tool like valgrind which allows to prevent memory leaks in a program, why the compiler doesn't use it and gives you the appropriate warnings? It would be too slow?
0
votes
1
answer
214
views
Pset 5 - valgrind errror because of memory leak
Succesfully finished Pset5 except for one memory leak error.
This is the Valgrind and Help50 report:
==32337==
==32337== HEAP SUMMARY:
==32337== in use at exit: 47 bytes in 1 blocks
==32337== ...
0
votes
1
answer
245
views
pset5 speller unload (trie) leaking memory
My unload function is leaking memory. Valgrind says that 8,960 bytes in 40 blocks were definitely lost, and 38,752 bytes in 173 blocks were indirectly lost. I'm not sure why...my unload function makes ...
0
votes
1
answer
58
views
pset5. Can unload words in dictionary but memory is definitely and indirectly lost
My unload function:
void clean(node* trav){
//Iterate over the trie structure
for(int i=0; i<CHILDREN_LENGTH; i++){
//Recursively delete deeper nodes if curent node is not null
...
0
votes
1
answer
283
views
PSET5: memory leak
Mem. leaking. help.
Only written load function but have the free function within load. Haven't fleshed out unload yet. Want to test that load works before fleshing out unload hence have included the ...
0
votes
1
answer
94
views
Pset5 all words are misspelled and Valgrind reports 15 errors
I can compile pset5 but when I run the program, it treats all words misspelled. Also, Valgrind reports 15 errors and help50 hints that I am trying to access 1 byte of memory that isn't mine. I have no ...
0
votes
1
answer
31
views
How/when to free this memory? (pset6/server)
Here is my implementation of the indexes function in pset6:
char* indexes(const char* path)
{
char* php = "index.php";
char* html = "index.html";
char* pathCopy = malloc(strlen(path) + ...
0
votes
1
answer
1k
views
Pset5: valgrind still reachable
My code passed the check50. But valgrind reported still reachable leaks. Some posts I'v read suggests that it is OK to have still reachable leaks. Is it really so? If not, how can I fix it? What does "...
0
votes
1
answer
716
views
per valgrind: multiple invalid read and invalid write; invalid free(); "still reachable: 568 bytes in 1 blocks"
My recover.c seems to recover all images correctly (per check50) but still seems to have issues with a couple of things per valgrind (output copied at the bottom). As background, I am using a ...
0
votes
1
answer
308
views
pset5 memory leak while using a Trie
I have implemented the different functions of this pset and I use a trie datastructure. However I run into several problems when I run the program. The output seems to be correct, but check50 says for ...
0
votes
1
answer
86
views
pset5: I am leaking all of my memory. What am I missing?
This problem set is becoming my bane. I have spent hours on it and I am still getting the same issues with valgrind (definitely losing 7 million bytes). I think my issues lie with load and check and ...