|
2011-02-27
, 22:08
|
Posts: 3,319 |
Thanked: 5,610 times |
Joined on Aug 2008
@ Finland
|
#162
|
Smart pointers sound interesting, I will look into this class. QPointers are also interesting. However, my idea was to mimic the pointer system via class that controlled a contiguous block (or blocks) and methods for controlling it. This is somewhat different than guarded pointers.
Out of curiosity (and don't answer if you don't want to), what type of programming do you do?
The Following 3 Users Say Thank You to attila77 For This Useful Post: | ||
|
2011-02-28
, 20:13
|
Posts: 1,341 |
Thanked: 708 times |
Joined on Feb 2010
|
#163
|
|
2011-02-28
, 20:35
|
Posts: 376 |
Thanked: 511 times |
Joined on Aug 2009
@ Greece
|
#164
|
|
2011-02-28
, 20:54
|
Posts: 1,341 |
Thanked: 708 times |
Joined on Feb 2010
|
#165
|
At first, a moving GC strategy may seem inefficient and costly compared to the non-moving approach, since much more work would appear to be required on each cycle. In fact, however, the moving GC strategy leads to several performance advantages, both during the garbage collection cycle itself and during actual program execution:
* No additional work is required to reclaim the space freed by dead objects; the entire region of memory from which reachable objects were moved can be considered free space. In contrast, a non-moving GC must visit each unreachable object and somehow record that the memory it alone occupied is available.
* Similarly, new objects can be allocated very quickly. Since large contiguous regions of memory are usually made available by the moving GC strategy, new objects can be allocated by simply incrementing a 'free memory' pointer. A non-moving strategy may, after some time, lead to a heavily fragmented heap, requiring expensive consultation of "free lists" of small available blocks of memory in order to allocate new objects.
* If an appropriate traversal order is used (such as cdr-first for list conses), objects that refer to each other frequently can be moved very close to each other in memory, increasing the likelihood that they will be located in the same cache line or virtual memory page. This can significantly speed up access to these objects through these references.
|
2011-02-28
, 20:55
|
Posts: 3,319 |
Thanked: 5,610 times |
Joined on Aug 2008
@ Finland
|
#166
|
The fancier smarter way, like defragmentation when needed, will be more inefficient in C++ than with Java JIT. Java JIT can use real pointers in its JIT'ed code, but C++ with a "fancy" memory management should have all pointers then indirect (or do code morphing). When GC in JVM notices there is fragmentation or the ratio of pagefaults has increased, it can re-arrange the objects and re-JIT the affected hotspots.
|
2011-02-28
, 21:19
|
Posts: 1,341 |
Thanked: 708 times |
Joined on Feb 2010
|
#167
|
Sorry. C++ can also be JIT-ed, garbage collected, and VM memory management is by no means a holy grail (if nothing else, the VM does not know about physical memory layout and architecture, which will always be an issue). C++ has moved past the '80s and Stroustrup, honest, and mobile contexts are a fairly unexplored area for JIT and proactive fancypants memory management.
|
2011-02-28
, 21:29
|
Posts: 376 |
Thanked: 511 times |
Joined on Aug 2009
@ Greece
|
#168
|
Read for example this:
And in all OOP-programs which have many variable size variable life time objects, you cannot really archive both high object locality and small fragmentation ratio, unless you use some kind of "moving-GC".
|
2011-02-28
, 22:12
|
Posts: 1,341 |
Thanked: 708 times |
Joined on Feb 2010
|
#169
|
|
2011-02-28
, 22:41
|
Posts: 376 |
Thanked: 511 times |
Joined on Aug 2009
@ Greece
|
#170
|
@v13: I think we are talking about little different heap memory fragmentation problems and effects here. I am mainly concerned (in this Java vs C++ issue) the increased pagefaults due to increasing heap memory fragmentation in long living OOP programs like www-browser. The problem with fragmentation is that locality of the objects is getting worse.
I do see Firefox still taking too much available RAM when it is runnign long time, but that is not why I restart it every few days, because the machine do not start swapping yet. But firefox seem to get slow, and restarting it makes a real difference. I notice this also if I disable flash. Javascript engine in Firefox has pretty good GC nowadays, so I don't think that is a problem but C++ memory management itself.
Tags |
bada rox, dalvik, future, java haters, meego, meego?fail, nokia, sandbox sucks |
|
Out of curiosity (and don't answer if you don't want to), what type of programming do you do?