Skip to main content

Posts

Showing posts from 2016

How to quickly investigate memory leak in your application

Every C/C++ software developer meet problem of memory leak (allocating memory over time which is not freed). If you would like to know how to investigate memory leak problem in your application, this article is for you. For memory leak investigation I recommend to use valgrind tool. Especially with it's Massif tool. Let's see the example how we could use that tool for memory leak investigation. Below snippet of code has lots of points where memory leak can occur. 1 #include <stdio.h> 2 3 void allocmem1 () 4 { 5 char * memleak 2 = malloc ( 100 * sizeof ( char )) ; 6 } 7 8 void allocmem2 () 9 { 10 char * memleak 2 = malloc ( 10 * sizeof ( char )) ; 11 allocmem1 () ; 12 } 13 14 void allocmem3 () 15 { 16 char * memleak 2 = malloc ( 5 * sizeof ( char )) ; 17 allocmem2 () ; 18 } 19 20 int main ( int argc , const char ** argv ) 21 { 22 char * memleak 1 = malloc ( 5 * sizeof ( char )) ; 23

How to speed-up make-based building process

If you are building some multifile-based project using make tool, it is worth to use parallel build in order to speed up building process. You can do that using -j option  of make tool ex. make -j2 If you will select -j2, you are informing your compiler to use 2 cores of your CPU for building process. The optimal option is to split build using all cores of your CPU. In order to get number of cores of your CPU on Linux-based OS you can use command: nproc Therefore, if you would like to speed-up build time optimally using all cores of you CPU, you can use following command on Linux-based OS: make -j`nproc` Picture source: http://hostme.ie/wp-content/uploads/2011/03/speed-up-wordpress.jpg

Linux - VIM as Integrated Development Environment (IDE)

In this post I would like to present you my configuration of vim text editor as Integrated Development Environment (IDE). In my daily work I am not using big IDE environments like Eclipse, NetBeans or other. Instead, I am using vim text editor configured with number of plugins, which contains all of most important features of traditional IDE environment and additionally I don't need to resign with VIM advantages like speed and flexibility. Using that VIM as IDE configuration I comfortably work with following programming languages on the daily basis: C/C++ Java Python Bash JavaScript HTML CSS My VIM as IDE configuration is publically available in github. You can clone it from here: git clone https://github.com/xmementoit/vim-ide It is under continous development so you can expect adding new features in the future. Video presentation of main features of my VIM as IDE environment can be found on youtube: I am aware that starting with big VIM as IDE configurati

Bash - useful bash aliases which I use in my daily work

~/projects/CppAdventureExamples/bash/aliases.html Bash alias is abbreviation of one terminal command (usually long command) using other terminal command (usually much shorter command). We can define aliases in bash dot files (ex. ~/.profile file). Example of bash alias: alias i="sudo apt-get install" Then we can install 'vim' package using 'i' alias this way (it works of Debian-based systems): i vim Today I would like to present few useful bash aliases which I use in my daily work. You can paste below aliases into your ~/.profile file (or ~/.bashrc) if you recognize them useful for you. Enjoy! #================================================================== # Listing aliases alias ll= "ls -lah" #list only directoriesj alias lsd= "ls -lF ${colorflag} | grep --color=never '^d'" alias sl= 'ls' #================================================================== #filter selected app fro