Posts

Showing posts with the label memory-leaks

Forgot to deallocate infinite chunk of memory

Forgot to deallocate infinite chunk of memory In my Ubuntu machine, Codeblocks software I allocated infinite chunk of memory without any deallocation. And after that my machine became slow. After restarting the system everything seems ok. Will be there any problem in future? You can't allocate an infinite chunk of memory in the first place. – user2357112 Jul 1 at 5:19 Memory allocated by the usual mechanisms ( malloc , calloc , new , mmap , ...) is internal to the process and will be released when the process dies. Shared memory allocations ( shmget , semget , ...) can persist after the process dies, but will not survive a reboot. So your system should be back to normal, with no lingering effects from the large allocation. – ottomeister Jul 1 at 23:45 ...

Valgrind reports SIGSEGV and use of uninitialised value

Valgrind reports SIGSEGV and use of uninitialised value Edit: All valgrind errors where solved by initialising i . i I am working with strings; reading strings from a file, separating them using strsep() , converting them to int using atol() . My code compiles on gcc and runs without errors, but when checked with valgrind I get the error mentioned in the title. strsep() atol() I am trying populate a two-dimensional array grid[20][20] with int values from a text file. The text file contains lines of numbers separated by spaces, something like 20 81 65 07 54 72 13 28 66 95 00 20 00 84 06 30 85 43 15 73n grid[20][20] 20 81 65 07 54 72 13 28 66 95 00 20 00 84 06 30 85 43 15 73n My code, (excluding all of the file IO) is as below. (Note that I do handle the file correctly: checking the result of fopen , closing with fclose ). fopen fclose #include <stdio.h> #include <stdlib.h> #include <string.h> #define STR_LEN 20 #define NUM_LINES 20 #define MAX_SIZE 100 int ma...