OutOfMemoryException when using FindDocumentByQuery on WinRT.

0 votes

Hello

I am developing an application for WinRT using the App42 SDK and I am trying to retrieve JSON documents using the StorageService FindDocumentByQuery() function but I keep getting an OutOfMemoryException whenever I call it. This only happens when I am passing in a compound Query which searches for 8+ documents which match 8+ different users OR'd together. So basically I am sending the query to find any documents with username = "user1" OR username = "user2" .... OR username = "user8". If I only search for 7 or less JSON documents then it works fine and I get no exceptions. Here is the relavant code that I am using:

List<Query> queries = new List<Query>();
Query mainQuery;
foreach (User user in this.UsersList)
{
    queries.Add(QueryBuilder.Build("username", user.username, Operator.EQUALS));
}
 
// Combine all the queries into one large query by OR'ing all the individual ones
if (queries.Count > 1)
{
    // I start the process outside the loop combining the first 2 to create the first main query object
    // that we will combine all the other queries into
    mainQuery = QueryBuilder.CompoundOperator(queries[0], Operator.OR, queries[1]);
 
    for (int i = 2; i < queries.Count; i++)
    {
        mainQuery = QueryBuilder.CompoundOperator(mainQuery, Operator.OR, queries[i]);
    }
}
// if there is only one user in the list then we only have 1 query
else
{
    mainQuery = queries[0];
}
 
storageService.FindDocumentByQuery(dbName, collectionName, mainQuery , new App42Callback());
 
Each document returned is about 300 characters long as a JSON string and the exception text is:
 
"An unhandled exception of type 'System.OutOfMemoryException' occurred in System.Net.ni.DLL
 
Additional information: Insufficient memory to continue the execution of the program."
 
Can you please help me with this?
asked Feb 7, 2015 in App42 Cloud API-BaaS by feraask (45 points)

1 Answer

0 votes
Hello Feraask,

Could you please reduce the size & number of JSON document while fetching from App42 data base. If it is faling than let us know.

Himanshu Sharma
answered Feb 7, 2015 by hs00105 (2,005 points)
As I mentioned, if I try to fetch 1-7 documents it works fine, but as soon as I try to fetch 8 it fails. Is there a limit to how many documents I can fetch at once?
Hello Feraask,

Could you please share the SDK version in which you are working on? Also please share your appname, dbname & collection in which you are working on. It will help us to debug the same at our end.
Thanks,
Himanshu Sharma
Here is the information you asked for:

SDK Version - App42 WinRT v1.0
App Name - FeraasAppWarpTest
DBName - TESTUSERS
Collection - Users

I have also created a very simple test application that demonstrates the problem, all you have to do is fill in the apiKey and secretKey for my FeraasAppWarpTest application in the MainPage.xaml.cs file. Also in the OnNavigatedTo method there are two username arrays, one of them with 7 names and one with 8, you can try both lists and notice that the one with 7 names works fine but the one with 8 does not.

Here is the code:
https://bitbucket.org/feraask/app42testwinrt/get/a4f2cec0f425.zip

Also, do you think you guys can let me know of the progress on all my other problems with the WinRT AppWarp and App42 SDKs? I haven't had any responses in a while and some of these are critical issues:

http://forum.shephertz.com/?qa=5231/how-do-i-setup-an-outlook-com-email-in-the-app42-email-service&show=5231#q5231

http://forum.shephertz.com/?qa=4979/getting-auth_error-connecting-quickly-after-disconnecting&show=4979#q4979

http://forum.shephertz.com/?qa=5141/appwarp-winrt-slow-connection-issues&show=5141#q5141

http://forum.shephertz.com/?qa=4929/connection-resiliency-returns-auth_error-windows-runtime&show=4929#q4929

Thanks for the help!
I have also now tested it using the FindDocumentsByQueryWithPaging() method where I just set max to 100 and offset to 0 and passed it the same query fetching 8 documents and I still had an OutOfMemoryException. The documents are only about 300 characters and if each character is 1 byte that is about 300 bytes per document and 8 documents would only be 8*300 = 2,400 bytes which is about 2.34KB which really should not cause an OutOfMemoryException, so it definitely seems like there is a bug here.
Hello Feraask,

Thanks for sharing the details & project with us. We are looking into it & update you very soon for this.

Thanks for your patience.

Himanshu Sharma
Hello Feraask,

It is a bug from our side and we have release the patch which is available to download. Kindly download the latest binary from the below link & let me know if it helps.

https://github.com/shephertz/App42_WINDOWS_SDK/tree/master/Windows_RT(8.1)_SDK

Also i have shared your links to our concern team, they will get back to you for the same.

Thanks,
Himanshu Sharma
Alright everything seems to be working so far with fetching 8 documents, thanks for help!
Thanks for your acknowledgement feraask :)
Himansh Sharma
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...