Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Gan via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 15:45:47 UTC, bearophile wrote: Gan: How can I make it use less CPU/RAM? Most tiny classes probably should be structs. More generally, use a struct every time you don't need a class. You can start with those two: struct SBRange { double left = 0.0,

Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread bearophile via Digitalmars-d-learn
Gan: Is there some special stuff I gotta do extra with structs? Do they need manually allocated and released? Most of your usages of tiny structs should be by value. So just keep in mind they are values. Even when you iterate with a foreach on a mutable array of them :-) On a second

Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Gan via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 19:26:12 UTC, bearophile wrote: Gan: Is there some special stuff I gotta do extra with structs? Do they need manually allocated and released? Most of your usages of tiny structs should be by value. So just keep in mind they are values. Even when you iterate

Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Gan via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 19:59:08 UTC, Gan wrote: On Tuesday, 27 January 2015 at 19:26:12 UTC, bearophile wrote: Gan: Is there some special stuff I gotta do extra with structs? Do they need manually allocated and released? Most of your usages of tiny structs should be by value. So

Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Rikki Cattermole via Digitalmars-d-learn
On 28/01/2015 9:59 a.m., Gan wrote: On Tuesday, 27 January 2015 at 19:59:08 UTC, Gan wrote: On Tuesday, 27 January 2015 at 19:26:12 UTC, bearophile wrote: Gan: Is there some special stuff I gotta do extra with structs? Do they need manually allocated and released? Most of your usages of

Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Rikki Cattermole via Digitalmars-d-learn
On 28/01/2015 11:30 a.m., Gan wrote: On Tuesday, 27 January 2015 at 21:36:51 UTC, Rikki Cattermole wrote: On 28/01/2015 9:59 a.m., Gan wrote: On Tuesday, 27 January 2015 at 19:59:08 UTC, Gan wrote: On Tuesday, 27 January 2015 at 19:26:12 UTC, bearophile wrote: Gan: Is there some special

Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Gan via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 22:30:13 UTC, Gan wrote: On Tuesday, 27 January 2015 at 21:36:51 UTC, Rikki Cattermole wrote: On 28/01/2015 9:59 a.m., Gan wrote: On Tuesday, 27 January 2015 at 19:59:08 UTC, Gan wrote: On Tuesday, 27 January 2015 at 19:26:12 UTC, bearophile wrote: Gan: Is

Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Vladimir Panteleev via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 22:39:31 UTC, Gan wrote: Would you know why this is using hundreds of mb of rams? Hi, What type is CircleShape? If it is a class, or otherwise contains pointers, then this is probably the source of your problem. You are storing high-entropy data

Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread FG via Digitalmars-d-learn
On 2015-01-27 at 23:39, Gan wrote: I commented out some stuff and it appears my massive memory consumption comes from my tile.redraw function: ... Would you know why this is using hundreds of mb of rams? Looks OK, so probably it is not the cause by itself. I would add a piece of code to

Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Rikki Cattermole via Digitalmars-d-learn
On 28/01/2015 11:39 a.m., Gan wrote: On Tuesday, 27 January 2015 at 22:30:13 UTC, Gan wrote: On Tuesday, 27 January 2015 at 21:36:51 UTC, Rikki Cattermole wrote: On 28/01/2015 9:59 a.m., Gan wrote: On Tuesday, 27 January 2015 at 19:59:08 UTC, Gan wrote: On Tuesday, 27 January 2015 at

Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Gan via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 21:36:51 UTC, Rikki Cattermole wrote: On 28/01/2015 9:59 a.m., Gan wrote: On Tuesday, 27 January 2015 at 19:59:08 UTC, Gan wrote: On Tuesday, 27 January 2015 at 19:26:12 UTC, bearophile wrote: Gan: Is there some special stuff I gotta do extra with structs? Do

Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Gan via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 22:42:25 UTC, Rikki Cattermole wrote: On 28/01/2015 11:39 a.m., Gan wrote: On Tuesday, 27 January 2015 at 22:30:13 UTC, Gan wrote: On Tuesday, 27 January 2015 at 21:36:51 UTC, Rikki Cattermole wrote: On 28/01/2015 9:59 a.m., Gan wrote: On Tuesday, 27 January

Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread FG via Digitalmars-d-learn
On 2015-01-28 at 03:04, Vladimir Panteleev wrote: What type is CircleShape? If it is a class, or otherwise contains pointers, then this is probably the source of your problem. class CircleShape : Shape is defined in dsfml.graphics.circleshape, so there's no going around this... - Building

Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Gan via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 02:50:11 UTC, FG wrote: On 2015-01-28 at 03:04, Vladimir Panteleev wrote: What type is CircleShape? If it is a class, or otherwise contains pointers, then this is probably the source of your problem. class CircleShape : Shape is defined in

I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread Gan via Digitalmars-d-learn
I feel like the only way I can get better right now is if someone with more knowledge can give me some advice on the code I have written. Here's the link: http://cl.ly/0s0Q1L1S3v0E How can I make it use less CPU/RAM? (Most code is in the Misc/SpaceBackground.d)

Re: I left my program open for 9 hours and it used up 700mb of ram, could someone review it?

2015-01-27 Thread bearophile via Digitalmars-d-learn
Gan: How can I make it use less CPU/RAM? Most tiny classes probably should be structs. More generally, use a struct every time you don't need a class. You can start with those two: struct SBRange { double left = 0.0, right = 0.0, top = 0.0, bottom = 0.0; } struct Point(T) { T x,