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

  • Home
  • SEARCH
  • 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 6734129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:51:08+00:00 2026-05-26T10:51:08+00:00

I have an asp page that accesses c++ code and gets a xml string

  • 0

I have an asp page that accesses c++ code and gets a xml string returned back. Whenever I access the webpage, I get a timeout in the web browser.

I think I know the problem but am not sure how to fix it. I am not sure how big the xml string will be so I am not sure what size to declare the variable to hold it so I declared iDataBufferSize as the biggest I can make it.

The following function has a for loop which is creating an xml string that gets returned back to the asp code.

The for loop needs to go through about 500 rows and I think when it hits this line wcscat_s(wDataBuffer, iSize, wBuffer);, it starts disk swapping and that slows down the for loop.

I know that when I make iDataBufferSize smaller, it works but I am afraid I will not make the buffer big enough for the xml string.

Thanks
-Dimitry

LPWCH wLargeDataBuffer = 0;
char *cLargeCBuffer = 0;
size_t iDataBufferSize = 93276800;   

wLargeDataBuffer = new WCHAR[iDataBufferSize];
cLargeCBuffer = new char[iDataBufferSize];

memset(wLargeDataBuffer, 0, iDataBufferSize);
memset(cLargeCBuffer, 0, iDataBufferSize);

iDataLen = getCServPBJList(wLargeDataBuffer, iDataBufferSize); 

int CAdminConsoleInterface::getCServPBJList(LPWCH wDataBuffer, size_t iSize) {
    wcscpy_s(wDataBuffer, iSize, L"<jobsList>");
    houseKeeper->getCServJobsXML(wDataBuffer, iSize, configHandler->getTextValue  (L"UniqueID"), L'P');
    wcscat_s(wDataBuffer, iSize, L"</jobsList>");
    return wcslen(wDataBuffer);
    } 

int CHouseKeeper::getCServJobsXML(LPWCH wDataBuffer, size_t iSize, LPWCH wLocation, WCHAR wPrefix) {
    WCHAR wIndexPath[1024];
    WCHAR wBuffer[1024];
    LPWCH wTempBuffer = new WCHAR[16384];
    int rc;
    char *zErrMsg=0;
    char **results;
    int nrow=0, ncol=0;
    char cSQLDB[1024];
    sqlite3 *CServDB;
    size_t convertedChars=0;
    size_t origsize;

    cout << "Looking up CServ jobs." << endl;
    getIndexPath(wIndexPath, 1024);
    wcscat_s(wIndexPath, 1024, L"CServ.db");
   WideCharToMultiByte(CP_UTF8, 0, wIndexPath, -1, cSQLDB, PATH_LENGTH, 0,0);

   //cout << "Opening DB: " << cSQLDB << endl;
   rc = sqlite3_open(cSQLDB, &CServDB);
   if (rc != SQLITE_OK)
   {
        cout << "Error opening DB." << endl;
        return -1;
   }
   rc = sqlite3_get_table(CServDB, "SELECT * FROM OServ_jobs;", &results, &nrow, &ncol, &zErrMsg);

   //cout << "nrow: " << nrow << " - ncol: " << ncol << endl;
   for (int i=1; i<=nrow; i++) {
       origsize = strlen(results[1+(ncol*i)]) + 1;
       mbstowcs_s(&convertedChars, wBuffer, origsize, results[1+(ncol*i)], 1024);
       wcscat_s(wDataBuffer, iSize, L"<job id=\"");
       wcscat_s(wDataBuffer, iSize, CHelper::escapeXMLData(wBuffer, wTempBuffer, 16384));
       wcscat_s(wDataBuffer, iSize, L"\" type=\"");
       //wcout << "JobID: " << wBuffer << endl;
       origsize = strlen(results[4+(ncol*i)]) + 1;
       mbstowcs_s(&convertedChars, wBuffer, origsize, results[4+(ncol*i)], 1024);
       wcscat_s(wDataBuffer, iSize, wBuffer);
       //wcout << "Type: " << wBuffer << endl;
       wcscat_s(wDataBuffer, iSize, L"\">");

       origsize = strlen(results[(ncol*i)]) + 1;
       mbstowcs_s(&convertedChars, wBuffer, origsize, results[(ncol*i)], 1024);
       wcscat_s(wDataBuffer, iSize, L"<currentLocation>");
       wcscat_s(wDataBuffer, iSize, wBuffer);
       //wcout << "Location: " << wBuffer << endl;
       wcscat_s(wDataBuffer, iSize, L"</currentLocation>");

       wcscat_s(wDataBuffer, iSize, L"<date>");
       origsize = strlen(results[2+(ncol*i)]) + 1;
       mbstowcs_s(&convertedChars, wBuffer, origsize, results[2+(ncol*i)], 1024);
       wcscat_s(wDataBuffer, iSize, wBuffer);
       //wcout << "Date: " << wBuffer << endl;
       wcscat_s(wDataBuffer, iSize, L"</date>");

       wcscat_s(wDataBuffer, iSize, L"<time>");
       origsize = strlen(results[3+(ncol*i)]) + 1;
       mbstowcs_s(&convertedChars, wBuffer, origsize, results[3+(ncol*i)], 1024);
       wcscat_s(wDataBuffer, iSize, wBuffer);
       //wcout << "Time: " << wBuffer << endl;
       wcscat_s(wDataBuffer, iSize, L"</time>");

       wcscat_s(wDataBuffer, iSize, L"</job>");

       memset(wBuffer, 0, 1024);
       memset(wTempBuffer, 0, 16384);
    }

    //wcout << "Data: " << wDataBuffer << endl;
    delete []wTempBuffer;
    sqlite3_free_table(results);
    sqlite3_close(CServDB);
    return wcslen(wDataBuffer);
}
  • 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-26T10:51:08+00:00Added an answer on May 26, 2026 at 10:51 am

    There’s an old parable about a man who paints lines down the road. The first hour, he gets 500 feet painted. The next hour, he only gets 300 feet painted. The next hour, only 100 feet. His boss asks him why he’s getting so slow, and he explains that it’s awfully hard to paint when the paint bucket is 1,000 feet away.

    You pass each concatenation call a pointer to the beginning of the line. It then has to walk to the line to find the end. Then it makes it a bit bigger. Ouch.

    Don’t make so many concatenation calls on such big strings. The simplest fix — use an intermediate buffer. On each iteration of your ‘for’ loop, concatenate into an intermediate buffer. And then use just one call to add that intermediate buffer to the main buffer. Ideally, on the call to add the intermediate buffer to the main buffer, pass a pointer further into the buffer rather than the beginning.

    In fact, the best solution is just to use some string class that has an efficient concatenation operation.

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

Sidebar

Related Questions

NET and VB.net code behind. I have a classic ASP page that connects to
I have an asp.net page that is trying to access a SSRS 2008 ReportServer
I have an asp page that loads a response user=exists everytime I try to
I have an ASP.Net page that will be hosted on a couple different servers,
I have an ASP.NET page that uses a repeater nested within another repeater to
I have an asp.net page that calls a dll that will start a long
I have an ASP.NET page that uses the ASP.NET Ajax Control Toolkit TabContainer .
We have an ASP.Net page that uses a checkbox to toggle between a list
I have an ASP.Net page that contains a <div> with an <img> tag within.
I have an ASP.NET page that calls to a WCF service. This WCF service

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.