Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6805487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:35:33+00:00 2026-05-26T19:35:33+00:00

This is the revised version. It takes 3.5GB memory and the pop function doesn’t

  • 0

This is the revised version.

It takes 3.5GB memory and the pop function doesn’t free the memory… How can I use new and delete to get those memory back? Now I’m using STL. since new and delete only works for pointers?

queue<Graphnode> ss;
    for(i=0;i<30000000;i++)
    {
        ss.push( *g.root);
    }

    printf("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n");
        for(i=0;i<30000000;i++)
    {
        ss.pop();
    }
    printf("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n");
    //delete &ss;

here is my node.h file. I think I need to malloc and free or New, delete pointers here?

#include <stdio.h>
#include <stdlib.h>
#include <tr1/array>

typedef struct point
{
    std::tr1::array<int, 16> state;
    int x;
}point;
typedef struct Graphnode
{
    struct point pvalue;
    int depth;
    struct Graphnode *up;
    struct Graphnode *down;
    struct Graphnode *left;
    struct Graphnode *right;
}Graphnode;

so after revise the code should look like this?

#include <stdio.h>
#include <stdlib.h>
#include <tr1/array>

typedef struct point
{
    std::tr1::array<int, 16> state;
    int x;
    int depth;
}point;
typedef struct Graphnode
{
    point *pvalue = (point *)malloc(sizeof(point));
    Graphnode *up = (Graphnode*)malloc(sizeof(Graphnode));
    Graphnode *down= (Graphnode*)malloc(sizeof(Graphnode));;
    Graphnode *left= (Graphnode*)malloc(sizeof(Graphnode));;
    Graphnode *right= (Graphnode*)malloc(sizeof(Graphnode));;
}Graphnode;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:35:33+00:00Added an answer on May 26, 2026 at 7:35 pm

    If you’re using c++, you should use queue<T> from the standard library. Here is a reference: http://www.cplusplus.com/reference/stl/queue/.

    For c++ code you should never write your own container classes unless it is absolutely necessary. The standard library provides many useful containers that cover most use cases. They are heavily used and tested and have been for many years.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Revised Code jQuery(function($) { $(#filter).keyup(function () { var filter = $(this).val(), count = 0;
This is a revised/better written version of the question I asked earlier today --
How do I maintain scope with this? Original var Base = new function() {
This is the revised version of my previous question Paralleling trading software The code
UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from
REVISED QUESTION : We have tracked this down to a custom add to cart
This is a bit of a long shot, but if anyone can figure it
When people refer to the revised syntax in OCaml, do they mean that this
I'm so use to timeline code, that this baffles me. How do I get
REVISED CODE AT THE END I'm very new to jquery, and even though I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.