Questions tagged [memory-leak]
The memory-leak tag has no usage guidance.
84 questions
1
vote
1
answer
82
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
2
answers
181
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
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
1
answer
60
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
2
answers
346
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(...
2
votes
1
answer
227
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 ...
0
votes
1
answer
159
views
CS50 PSET5 Memory Leak (updated2)
I had posted two questions regarding memory leak in Problem Set 5, available at CS50 PSET5 Memory Leak and CS50 PSET5 Memory Leak (updated). I got amazing feedback from different people (and I ...
1
vote
1
answer
156
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....
0
votes
1
answer
32
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) + ...
2
votes
1
answer
381
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 ...
0
votes
1
answer
172
views
CS50 PSET5 Memory Leak
I have spent more than 30 hours on this problem set and I am still struggling. At first, my program compiled but did not run, due to a segmentation fault. I finally fixed it and everything works fine, ...
0
votes
1
answer
2k
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
245
views
pset5 unload recursion causes memory leaks
In pset5, I have made load (using a trie), check and size run successfully, even my whole codes passed check50. I believe so because when I do spell check a text using the big library, I get the same ...
1
vote
1
answer
80
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
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
2k
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
1
answer
772
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
225
views
pset4 recover.c valgrind claims there is unfreed memory. I'd like to know how/why?
I just finished recover.c in pset4. It compiles, runs, and creates all the jpgs just fine, but valgrind gives me the following leak summary (full leak summary at bottom):
==15709== LEAK SUMMARY:
==...
0
votes
2
answers
66
views
2D array of given size
I want to create a 2D array of ints, where the array's dimension is given at run time (not compile time). So far, I have been using:
int **ptr = malloc(m * sizeof(int*));
for (size_t i = 0; i < m;...
1
vote
1
answer
853
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 ...
0
votes
2
answers
281
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
313
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
393
views
Pset5 memory leak with unload
I have completed the code for pset5 but I have a super big memory leak which i believe comes from not pointing each backed in the hash_table correctly. Below I have unload function and valgrind's ...
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 ...
0
votes
1
answer
322
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
206
views
pset 5 memory leak - how struct definition may be related
I saw a similar question about memory leaks with speller "pset5 valgrind memory leaks", but that poster found a solution that doesn't seem to work at all for my program. Just like that user, I get ...
0
votes
1
answer
620
views
Can't make Valgrind happy in Speller (pset5)
I'm working through ./speller in pset5, mainly the load() function. My function loads the dictionary without any issues, and Valgrind even shows no memory leaks. The problem is I have a ridiculous ...
0
votes
1
answer
193
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....
1
vote
1
answer
786
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, ...
0
votes
2
answers
171
views
memory leak on the stack?
Just wondering if anyone can explain why we are concerned with memory leak in the heap (freeing for example a char *), but we are not concerned with freeing variables that are in the stack in the main ...
2
votes
1
answer
618
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
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;
}...