Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter Beta
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Orbiter Beta Topics related to Beta releases of Orbiter and Orbiter development.

Reply
 
Thread Tools
Old 03-28-2015, 10:12 PM   #16
TCR_500
Biblical Creationist
 
TCR_500's Avatar
Default

Quote:
Originally Posted by Urwumpe View Post
 Those are all 404 errors.
The closing brackets got into the links (stupid URL parser!). Remove them and they'll work.
TCR_500 is offline   Reply With Quote
Old 03-28-2015, 10:45 PM   #17
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by kuddel View Post
 Not if you remove the trailing bracket (])
So : http://www.lb-stuff.com/cc and http://www.lb-stuff.com/pointers
OK... read it.... now I question the sanity of the author.

The typical "dogma over requirements"-programmer speaking.
Urwumpe is offline   Reply With Quote
Thanked by:
Old 03-28-2015, 11:14 PM   #18
martins
Orbiter Founder
Default

Should I ever rewrite Orbiter in another life, maybe I'll go for a rock solid programming language that will never ever update its specification. What about
brain:censored: brain:censored:
? Pure and, ahem, simple. Not sure about support for 3D graphics libraries though ...

Edit: hm, the forum censor even messed up the link - not so smart. Anyway, you know what I mean and where to look for it.

Edit 2: This is, I think, the first time I've ever been censored on the forum - for a programming language! Weirdly fitting ...
martins is offline   Reply With Quote
Old 03-28-2015, 11:17 PM   #19
ADSWNJ
Scientist
 
ADSWNJ's Avatar
Default

I'm not suggesting to not use the Standard Library, but just be aware of the limitations. And I still reiterate that it's not a "compliance" failing to use the language w/o the library.
ADSWNJ is offline   Reply With Quote
Old 03-28-2015, 11:25 PM   #20
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by martins View Post
 Should I ever rewrite Orbiter in another life, maybe I'll go for a rock solid programming language that will never ever update its specification. What about brain? Pure and, ahem, simple. Not sure about support for 3D graphics libraries though ...
What about using Haskell? It can do everything and is self-optimizing....


Oh wait, yes, this little tiny detail....
Urwumpe is offline   Reply With Quote
Old 03-29-2015, 12:22 AM   #21
TCR_500
Biblical Creationist
 
TCR_500's Avatar
Default

Hmm, looks like somebody at one of the C++ help forums lied to me about my code with raw pointers producing memory leaks!
TCR_500 is offline   Reply With Quote
Old 03-29-2015, 12:29 AM   #22
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by TCR_500 View Post
 Hmm, looks like somebody at one of the C++ help forums lied to me about my code with raw pointers producing memory leaks!
Yes, maybe. Maybe it does produce such leaks. Maybe not. Depends on the lifecycle of the objects that you create. If a path is possible in which the memory is allocated, but not freed before you "forget" the reference to it, you will produce possibly memory leaks.
Urwumpe is offline   Reply With Quote
Old 03-29-2015, 12:38 AM   #23
TCR_500
Biblical Creationist
 
TCR_500's Avatar
Default

My code made sure to delete the references when I was done with it. And I checked with a simple test application. So far, no memory leaks detected!
TCR_500 is offline   Reply With Quote
Old 03-29-2015, 12:42 AM   #24
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by TCR_500 View Post
 My code made sure to delete the references when I was done with it. And I checked with a simple test application. So far, no memory leaks detected!
Really? Or do you just have faith in it?
Urwumpe is offline   Reply With Quote
Old 03-29-2015, 02:08 AM   #25
TCR_500
Biblical Creationist
 
TCR_500's Avatar
Default

Complete Test results:
Raw Pointers, config a (10000 loop iterations): ~14 mb of memory used.
Raw Pointers, config b (10000 loop iterations): ~9 mb of memory used.
std::vector of std::shared_ptr (10000 loop iterations): ~12 mb of memory used.
std::vector of std::unique_ptr (10000 loop iteration): ~10 mb of memory used.

If we assume that std::vector, std::shared_ptr and std::unique_ptr are "leak-proofed," that means my test code with raw pointers using new[] and delete[] has no memory leaks! However, my research indicates that "fragmentation" is quite the issue.

Of course, when the std::vector::clear() and std::vector::pop_back() functions cause the application to crash, one has to wonder if the std::vector is really "safe." Especially when I got a lower memory usage using raw pointers.

For "Raw Pointers, config a," I created an array of 10 object pointers, copied that array to an array of 15 object pointers (adding 5 new objects), and then re-copied that to the original array which was expanded to fit the 5 additional object pointers. Each time an array was copied to a new array, the previous array was deleted. At the end of each loop iteration, the expanded, original array was also deleted. At the beginning of each loop iteration, the original array (which was on global scope) was re-initialized.

For "Raw Pointers, config b," I created an array of 10 object pointers, copied that array to an array of the same size, then re-copied that to the original array. Each time an array was copied to a new array, the previous array was deleted. At the end of each loop iteration, the original array was also deleted. At the beginning of each loop iteration, the original array (which was on global scope) was re-initialized.

The std::vector tests used array sizes of 10 std::shared_ptr or 10 std::unique_ptr and no attempt to increase the size was made.

Quote:
Originally Posted by Urwumpe View Post
 Really? Or do you just have faith in it?
From these test results, I think I'm going to put more faith in raw pointers than I will the new std::vector.
TCR_500 is offline   Reply With Quote
Old 03-29-2015, 05:06 AM   #26
Enjo
Mostly harmless
 
Enjo's Avatar


Default

Quote:
Originally Posted by ADSWNJ View Post
 I think it's the std::string that bites the unaware user, when passed across modules that are implemented under different versions of the standard library. Enjo and I saw this for real with ModuleMessaging early on between his code and mine, due to a different MSVC.
That was HUDDrawer SDK. We've found a way around it - using const char *. When it comes to ModuleMessaging, then const char * won't work, but there are other ways around it - either using indexes of objects, or passing a pointer (hence: integer) to a struct, containing a string, throughout the modules, like ADSWNJ found out.

Quote:
Originally Posted by ADSWNJ View Post
 For OP - note that there is absolutely no requirement in C++ to use the std library if you don't want to, so it's incorrect to state it as non-compliant to use char* or whatever you like from the lexical capabilities of the language.
The const char * wouldn't break any modules for sure, and would maybe save Orbiter's face from some of CTDs that are too frequent in this sim. Const correctness doesn't take much time to implement and was suggested years ago.

Last edited by Enjo; 03-29-2015 at 06:04 AM.
Enjo is offline   Reply With Quote
Thanked by:
Old 03-29-2015, 08:10 AM   #27
Face
Beta Tester
 
Face's Avatar

Default

Quote:
Originally Posted by TCR_500 View Post
 Hmm, looks like somebody at one of the C++ help forums lied to me about my code with raw pointers producing memory leaks!
If somebody tells you that using raw pointers will always produce memory leaks, he is lying.

If somebody tells you that by using managed objects you will never produce memory leaks, he is lying, too.

Dogma Driven Development used by Voodoo Programmers is always fun to watch...

---------- Post added at 10:10 ---------- Previous post was at 10:03 ----------

Quote:
Originally Posted by martins View Post
 Should I ever rewrite Orbiter in another life, maybe I'll go for a rock solid programming language that will never ever update its specification. What about brain? Pure and, ahem, simple. Not sure about support for 3D graphics libraries though ...
At work, we once joked about the idea of making an FPGA resembling a multi-core CPU SoC solution (i.e. with bus and RAM integrated) that works directly on BF code. So if you do that, I'll make sure there is the hardware to run it on .
Face is offline   Reply With Quote
Reply

  Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter Beta


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 05:16 AM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.