Re: [Vala] memory management class struct



On Sat, 2008-08-23 at 10:00 -0300, Martin (OpenGeoMap) wrote:
Hi:

Someone know how c++ manage the member in classes. 
You might want to read this.
http://en.wikipedia.org/wiki/Virtual_table

Look at the examples section. The vtable pointer in is similar to
GTypeInstance member in GLib.

I guess if there is no virtual member functions, there is no
GTypeInstance alike field in C++(gcc at least)'s memory layout. I didn't
find a ref source to support my assumptions.

For your case if you don't use any features that requires a vtable, each
of your lidar point object will use sizeof(GTypeInstance) less memory in
g++ than in GLib. A overhead of around several mega bytes for GLib code.

Yu
I am asking this 
because in vala i know member funcions in classes are shared between all 
objects. This is important for me because if i want build engineering 
apps i use many entities of the same class. For example for the lidar 
point class i have to use 1 million of instances of the same class.

I see blender is 100% C source code in the kernel, but for example K-3D 
is C++ pure code with extensive use of STL.
I know microstation kernel is C pure code because i have the header of 
all entities of the DGN format and itÅ› only C structs.

/* Our "Instance struct" defines all the data fields that make our object unique. */f 
typedef struct _SomeObject SomeObject;
struct _SomeObject
{
      GTypeInstance   gtype;

      gint            m_a;
      gchar*          m_b;
      gfloat          m_c;
};

/* Our "Class struct" defines all the method functions that our objects will share. */
typedef struct _SomeObjectClass SomeObjectClass;
struct _SomeObjectClass
{
      GTypeClass      gtypeclass;

      void            (*method1)      (SomeObject *self, gint);
      void            (*method2)      (SomeObject *self, gchar*);
};



Regards.


_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]