Archive for July, 2008

Heap allocation experiment

Various compilers use different amount of memory spaces in heaps. As I compiled programs in GCC, MinGW GCC, and Microsoft Visual C++, I found different result. At a 100 byte char array, Visual C++ 2008 left 126 bytes before allocating another array, MinGW GCC left 112 bytes and in Ubuntu 8.10 Hardy, the built in GCC left 104 bytes. I used an P4 (which is a 686, supports EM64T), with 1536 MBs of RAM. And I got the mentioned results. My experiment was this:

#include <stdio.h>
#include <stdlib.h>
#define MAX 100

int main(int argc, char *argv[]){
int i;
FILE *output;
output=fopen(“data_hack1″,”w”);
fprintf(output,”char\n”);
for(i=1; i<=MAX; i++){
char *array1=(char*)malloc(i);
char *array2=(char*)malloc(1);
fprintf(output,”The free space for %d length int array is %d\n”,i,array2-array1);
}
fprintf(output,”\n\n”);

return 0;
}

You may compile and see the result yourself in the file named data.txt. You should also note what compiler and system you are using. You may also send me the result, by email (rivalslayer@yahoo.co.in) or commenting this post.

You can also try out this, and see the difference between allocating int and char.

#include <stdio.h>
#include <stdlib.h>
#define MAX 100

int main(int argc, char *argv[]){
int i;
FILE *output;
output=fopen(“data_hack2″,”w”);
for(i=1; i<=MAX; i++){
int *array1=(int*)malloc(i);
int *array2=(int*)malloc(1);
fprintf(output,”The free space for %d length int array is %d\n”,i,array2-array1);
}
fprintf(output,”\n\n”);
return 0;
}

This is also a program, which you can try out. In Ubuntu 8.10 GCC, for a 100 byte array, the program left about 26 bytes. I don’t know why! I haven’t tried this one out in other OS and compilers yet.

Fun with a pet Python and DOM

Well, I didn’t say that my pet Python is a snake, it is actually a scripting language. Very nice language! It has great libraries, very powerful built-in data types, awesome syntax structure. And the best part is that it can be learned in very few days. I did not take much time too.

I always wanted to handle data in the form of XML. Two days ago, I found a ebook on Python and XML. I tried that out. The first part was on SAX (Simple API for XML). I found SAX’s working very difficult. Then I went to DOM (Document Object Model), and found it very intuitive, and a breeze to use. The online resources say that SAX is good for large data handling, and DOM is better for complex XML files. I don’t know about SAX, so I cannot give you my opinion about SAX. But the experience with DOM was great. It was fun; only in two evenings, I can read and write XML with DOM easily. At first, XML handling appeared to be very complex stuff while I started off with SAX, all those extension classes, objects, call backs, really it was a bit difficult at first glance. Now I think I should move to some more complex programming, like SAX, web programming with Python maybe, JavaScript and AJAX.

My plan at first to was to build a local .rpm repository designer for Fedora, for I badly needed that. I will be building that soon, as I now know bit of PyGTK and bit of DOM, it won’t be much difficult. But, I don’t really use Fedora now, so…

My friends ask me why I keep sitting at the front of my computer all the time, trying to programme some job, or hacking my ubuntu to do something, or writing some shell script. I cannot reply them. It’s just plain fun!

C cracking my nerves!

That is why I like python more and more and more. I was just trying out a program, using linked list. That was the beginning, and within an hour, I still cannot make up that simple program when I employed linked list algo. Damn! All those low level memory management, and I cannot concentrate on the program yet! This language named C is I think for Geeks only (I am also a geek but…)! My dear Python will manage up all the low level management itself! That’s the beauty, so that I can concentrate on the finer details of my program.

Ooof! The monsoon heat mixed up with nerve wracking simple but lethal linked list, it is truely an experience!

Fedora 8 to Hardy to Fedora 9 to Hardy again!

I used Fedora 6 then Fedora 7 then Fedora 8! And I awaited for Fedora 9. I had few problems with Fedora, it had a bug with Java, it didn’t work! Fedora 8 did not have a driver for my XEROX Phaser 3117 printer. All else was good for me. My work revolves around Python, PyGTK, GTK+, C++ etc. So, there was no problem for me. It was great. But I looked forward to Fedora 9, as it should have good support for my printer, Java etc. etc.

Then Canonical generously sent me a Hardy(Ubuntu 8.04) CD. I tried that our, and saw that it supports my printer and Java also. “Great”, I thought, I switched to Ubuntu for temporarily, while waiting for Fedora 9. Ubuntu has everything under control! But the lack of the root account was a bit of a trouble, but I soon got used to it. I enabled 3D Hardware rendering by installing the driver from ATI. And it was going great! I installed softwares I needed for my work, like Komodo Edit.

Then I got my hands on Fedora 9. Last week, I was really excited, that I had the new Fedora! I installed it, and I was disappointed. The distro felt incomplete. It didn’t have a good proprietary driver for my graphics card. It had bits of bugs. It was really not better than Ubuntu as I thought it would be. I didn’t even tried out Java on that distro.

I finally realised the difference between Ubuntu and Fedora. I always thought, that Fedora was no less than Ubuntu. I really could not understand why everyone keep saying that Ubuntu is better and popular than Fedora. Hey, Fedora! Don’t take me otherwise, there is no offence! It is just that one month using Ubuntu, and when I went back to Fedora, it really didn’t feel right! Fedora 8 was far more stable, robust! But Fedora 9 is not that good I think. Please don’t mind Fedora! I am still a big fan of Fedora as I am of Ubuntu! I would gladly use Fedora 8, only if it had a bit better out of the box hardware support.

Then, with sad heart I went back to Ubuntu 8.04 Hardy Heron. I am blogging from that right now. I have already installed what I need, mp4 support, so that I can listen to Tiesto podcasts from Radio 538, I installed mp3 support for music, ATI Fire GL driver, gnuplot etc. etc. And for my works, I am using Komodo Edit, and NetBeans (the most sexiest IDE). Life is fun again, but I can see the unused Fedora 9 DVD lying on the table.

…l0v(e)^%v(r^me)

Reign Over Me

Love Reign Over Me!

It’s time!

I am a bit sorry that I didn’t show myself off a little earlier. I never liked show offs. I think that I needed to show off a little bit; If you never show off, how can everyone else know what you really are. Isn’t that true, I think it is a bit logical, and how I came to know it? It was real treat when you know that you really pulled off something good.  Basically, it was a group theory instinct! We have a XEROX Phaser 3117 monochrome laser printer. My father had to print something with a letter headed page. Being my printer assistance, I had to make sure when the page comes out which side is up on the page, so that the print corresponds with the letter head. I was sure that the page will come out with the initial up side down, but my father argued that I couldn’t understand a simple thing, so that I should make a mark on the page first. But if you see the XEROX Phaser printer in action, then you can easily make out my argument, logically. You don’t really need group theory, you just need a bit of logical arguments to prove that. Try that, you will like it. I did the proof in a second, but my father could not understand that I did that in my mind, and I did not had to test print.

And that is why now I think it’s time that I show off something so that the people who matters most to me really know that I am not as DULL as they think I am (and I am sure that they think I am a real DULL guy).

P.S. Showing off now: According to my observation, a bit advanced logic sometimes appears meaningless…


Tweets

  • Experts say you really need to learn assembly if you want to become and embedded systems engineer......1 day ago
  • Learning assembly programming for better memory management in PIC16F, though I was fine with C.... XD...1 day ago
  • AVRGCC has better online docs than HI-TECH C Compiler from Microchip...! :( But still 16F are pretty good with me... He He! XD...2 days ago
  • Up and running with PIC16F628A, it is a good microcontroller to learn with, rather than that old PIC16F84A, which is out of production......2 days ago
  • Programmed a PIC!...3 days ago

Categories

rivalslayer - Flickriver
Ubuntu: For Desktops, Servers, Netbooks and in the cloud