Memory issue...

This is a discussion on Memory issue... within the Windows Programming forums, part of the Platform Specific Boards category; Hello. I am working on a browser. After parsing the web-page, I will be creating a class Graphic node and ...

  1. #1
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,652

    Memory issue...

    Hello. I am working on a browser. After parsing the web-page, I will be creating a class Graphic node and attaching it to the first and so on. After the user hops to another page, I will be freeing the memory of the class Graphic linked list objects, and renew the process. My question is, is this a bad idea? Would an array of Graphic objects be better since each element is reused, or will Windows be properly reclaiming the memory deallocated from the linked list version?
    Code:
    #include <ip.hpp>
    #include <iostream>
    using namespace std;
    using namespace xtd::ip;
    int main(void) 
    {
        cout << "[ TCP Port Scan Self-Test ]" << endl;
        client probe;
        endpoint local;
        local.address = "127.0.0.1";
        local.protocol = IPPROTO_TCP;
        for(local.port = 0; local.port < (1 << 16); ++local.port)
        {
            if(probe.open(local))
                cout << "Listening: ";
            else
                cout << "No Response: ";
            cout << local.port << endl;
        }    
    }

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I don't think anyone here really knows whether or not windows reallocations and redistributes memory well or not. I think we all assume that it does. And that assumption has taken many of us far You should do it dynamically since static allocation has limitations to the static heap. If you make an large heap to overcome limitations you create a large memory hog that didn't need to be there in the first place. You want to avoid memory waste more than anything else.

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    As long as you free any memory you've allocated, and any GDI objects you've created, Windows will free up the memory. Do not, however, expect to see the memory usage figure change smoothly, i.e. allocating a 100 bytes may or may not increase your tasks memory allocation, similaly, freeing some memory may not change the allocation.

    The memory manager allocates and deallocates memory in largeish chunks, and does so as required by the system rather than the vagaries of the program.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,652
    Thanks, guys!
    Code:
    #include <ip.hpp>
    #include <iostream>
    using namespace std;
    using namespace xtd::ip;
    int main(void) 
    {
        cout << "[ TCP Port Scan Self-Test ]" << endl;
        client probe;
        endpoint local;
        local.address = "127.0.0.1";
        local.protocol = IPPROTO_TCP;
        for(local.port = 0; local.port < (1 << 16); ++local.port)
        {
            if(probe.open(local))
                cout << "Listening: ";
            else
                cout << "No Response: ";
            cout << local.port << endl;
        }    
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help finding potential Memory issue
    By JoshNCSU22 in forum C Programming
    Replies: 9
    Last Post: 10-29-2008, 09:58 AM
  2. What's the difference?
    By Stonehambey in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 10:26 AM
  3. threads and memory issue
    By Anubhav in forum C Programming
    Replies: 6
    Last Post: 07-25-2006, 04:51 AM
  4. Memory Leak Help
    By (TNT) in forum Windows Programming
    Replies: 3
    Last Post: 06-19-2006, 11:22 AM
  5. Accessing Video Memory Information...need help
    By KneeLess in forum C++ Programming
    Replies: 8
    Last Post: 08-24-2003, 03:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21