Thread: Minimizing Memory

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    8

    Minimizing Memory

    Hi there,

    This is kind of a general question.
    Recently I made an application using C++ Builder.
    I pressed the CTRL+ALT+DEL to see how much memory my program used.
    I saw that it used about 6 K. All the other running applications had between 1 and 2 K.
    I must be doing something wrong, and my program uses a lot of memory.
    Could it be from the fact, that I'm using 3 thread objects,and 2 Forms inside the project? They don't seem too much to me.

    Could someone please explain to me what should I do in the future to minimize the memory needed by my application?

  2. #2
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    a) Compile in Release mode if you're using MSVC++
    b) Minimize the use of unneccessary variables (note, unneccessary)
    c) delete[] arrays, not delete, and make sure that you do
    d) Not sure, but threads might take up some memory
    e) Avoid "double array[9999999];"
    f) Just kidding.

    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    g) Dynamically alloc memory as needed and free asap.


    >>I saw that it used about 6 K. All the other running applications had between 1 and 2 K.

    LOL! a whole 6K! You resource hogg!

    The other apps may not be running / working / using CPU / holding much data.

    6K is nothing, as long as it is stable( does not increase over time, has no leaks). 6K a second is a problem....



    An app I wrote uses over 40Mb to init, then it starts downloading data and uncompressing it...... This can quickly get to around 100Mb....
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Registered User
    Join Date
    Jun 2003
    Posts
    245
    since you are using Builder, Make sure you allocate the forms dynamically (using new), rather than creating them all at the same time in the main part of the project.

  5. #5
    Registered User
    Join Date
    Jun 2003
    Posts
    8
    Novacain,

    You missunderstood what I said.
    I didn't say that 6 K is enormous,
    it's just that it's a very small app, and I think that for that kind of app 6K is enormous.Just that,and nothing more.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. available memory from task manager
    By George2 in forum Tech Board
    Replies: 10
    Last Post: 01-18-2008, 02:32 AM
  2. Replies: 4
    Last Post: 01-13-2008, 02:14 AM
  3. Question regarding Memory Leak
    By clegs in forum C++ Programming
    Replies: 29
    Last Post: 12-07-2007, 01:57 AM
  4. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  5. Shared Memory - shmget questions
    By hendler in forum C Programming
    Replies: 1
    Last Post: 11-29-2005, 02:15 AM