digitalmars.D.learn - How much memory is used by an object?
- Alexandr Druzhinin (7/7) Feb 18 2013 Suddenly I detect that my application is using too much memory, so I
- bearophile (6/12) Feb 18 2013 Try:
- Alexandr Druzhinin (4/16) Feb 18 2013 Thanks a lot!
- Jacob Carlborg (5/12) Feb 18 2013 An object will contain some hidden members as well. Try this:
- Alexandr Druzhinin (6/7) Feb 18 2013 I agree. But hidden member can't occupy so much memory that I disturb so...
- Jacob Carlborg (7/12) Feb 18 2013 Some things to take into consideration:
- Alexandr Druzhinin (5/6) Feb 18 2013 and this the next problem I get - the application eats memory always. in...
- H. S. Teoh (9/12) Feb 18 2013 [...]
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (4/12) Feb 18 2013 Try to build as a 64-bit application. If it helps, you may be seeing the...
- Jacob Carlborg (10/14) Feb 18 2013 The GC works like this:
Suddenly I detect that my application is using too much memory, so I need some way to know how much memory is used by some object to improve the app. How can I do it? I've used some OS specific things but they aren't convenient because provide information about the whole application, instead of the specific class instance. Simple size calculation of class fields doesn't correspond to memory consumption.
Feb 18 2013
Alexandr Druzhinin:so I need some way to know how much memory is used by some object to improve the app. How can I do it?I've used some OS specific things but they aren't convenient because provide information about the whole application, instead of the specific class instance. Simple size calculation of class fields doesn't correspond to memory consumption.Try: http://dlang.org/traits.html#classInstanceSize Also, the GC has some useful hooks. Bye, bearophile
Feb 18 2013
18.02.2013 20:54, bearophile пишет:Alexandr Druzhinin:Thanks a lot! Also, what hooks do you mean? I look at core.memory and don't see anything like hooks... I'd appreciate this information.so I need some way to know how much memory is used by some object to improve the app. How can I do it?I've used some OS specific things but they aren't convenient because provide information about the whole application, instead of the specific class instance. Simple size calculation of class fields doesn't correspond to memory consumption.Try: http://dlang.org/traits.html#classInstanceSize Also, the GC has some useful hooks. Bye, bearophile
Feb 18 2013
On 2013-02-18 13:43, Alexandr Druzhinin wrote:Suddenly I detect that my application is using too much memory, so I need some way to know how much memory is used by some object to improve the app. How can I do it? I've used some OS specific things but they aren't convenient because provide information about the whole application, instead of the specific class instance. Simple size calculation of class fields doesn't correspond to memory consumption.An object will contain some hidden members as well. Try this: http://dlang.org/traits.html#classInstanceSize -- /Jacob Carlborg
Feb 18 2013
18.02.2013 21:23, Jacob Carlborg пишет:An object will contain some hidden members as well.I agree. But hidden member can't occupy so much memory that I disturb so much. I'm sure I use memory allocation in wrong manner but I haven't glue so far. Manual memory allocating is simpler for me than gc - I mean it's more explicit.
Feb 18 2013
On 2013-02-18 15:53, Alexandr Druzhinin wrote:I agree. But hidden member can't occupy so much memory that I disturb so much. I'm sure I use memory allocation in wrong manner but I haven't glue so far. Manual memory allocating is simpler for me than gc - I mean it's more explicit.Some things to take into consideration: * The GC will always allocate in chunks and may therefore use more than expected memory * The GC will never give back memory to the OS which it has allocated -- /Jacob Carlborg
Feb 18 2013
18.02.2013 22:39, Jacob Carlborg пишет:* The GC will never give back memory to the OS which it has allocatedand this the next problem I get - the application eats memory always. in C++ I'd say it is leaks but with gc I'm not sure it is - I guess gc collects memory but I don't see in reality. I think I don't understand something important and now I read from the start.
Feb 18 2013
On Mon, Feb 18, 2013 at 11:13:25PM +0700, Alexandr Druzhinin wrote:18.02.2013 22:39, Jacob Carlborg пишет:[...] Take a look at GC.minimize() here: http://dlang.org/phobos/core_memory.html Or does that not work at the moment? T -- Having a smoking section in a restaurant is like having a peeing section in a swimming pool. -- Edward Burr* The GC will never give back memory to the OS which it has allocated
Feb 18 2013
On 02/18/2013 08:13 AM, Alexandr Druzhinin wrote:18.02.2013 22:39, Jacob Carlborg пишет:Try to build as a 64-bit application. If it helps, you may be seeing the effects of the current GC implementation being conservative. Ali* The GC will never give back memory to the OS which it has allocatedand this the next problem I get - the application eats memory always. in C++ I'd say it is leaks but with gc I'm not sure it is - I guess gc collects memory but I don't see in reality. I think I don't understand something important and now I read from the start.
Feb 18 2013
On 2013-02-18 17:13, Alexandr Druzhinin wrote:and this the next problem I get - the application eats memory always. in C++ I'd say it is leaks but with gc I'm not sure it is - I guess gc collects memory but I don't see in reality. I think I don't understand something important and now I read from the start.The GC works like this: 1. Request memory 2. No memory is available 3. Run a collect cycle 4. If memory still isn't available allocate more from the OS When it runs a collect it will keep the memory so it can used it for future allocations instead of give it back to the OS. -- /Jacob Carlborg
Feb 18 2013