Optimisation of React-Native app memory while fetching Data from network - axios

I am working with a React-Native app and i have some FlatList Component inside it and it is using round bout 100MB of memory but the problem i am facing is when i make some network request and after getting response from network request it start using memory of near about 500MB but according to PostMan this service response size is 18.66KB I also have implemented pagination so when FlatList's scroll finishes i make another call but this time memory is not increasing rapidly as it was increasing previously.
I am using Redux-saga for state management and i also disptach and action in componentWillUnMount to clear the state of redux but app memory not clearing it at all.
and here is post man response time and size

Related

Precaching network responses using `Isolates` with Dio and Hive

I just want to precache some endpoint calls at the beginning of the app to load faster some request since the backend service is really slow.
I've tried using Isolates for this but seems like Hive Cache doesn't support that, so even if I try to request on another Isolate it will ended up taking the same time (20-30 seconds) the same request when I'm trying to pull for the second time, where it should cache it.
Since I read it wasn't supported yet, and I personally think is critical, I moved to just call the endpoints meanwhile the app is loading a bunch of stuff in the main thread. I dont want to delay any more the app so I just want to preload 5 endpoints, so that the next time I'm requesting again it can perform faster.
1. First Approach, with Isolates
I'm calling this inside a function
final requestsToPrecache = events
.map((entityId) =>
_dataRepository.getEventTable(entityId: entityId))
.toList();
compute(precacheFutureOperations, requestsToPrecache);
Then this function is the one I'm passing thru Isolates
void precacheFutureOperations(List<Future> functions) {
Future.wait(functions);
}
2. Second Approach, just not calling await on the Network Request to trigger the request and cache them, so I dont need to wait for the response since I just want to execute it and keep it in cache before it is used, so I just call b
precacheFutureOperations(requestsToPrecache);
All of this trigger the endpoints I want to precache succesfully, I am monitoring that using proxyman. The weird part is that it doesnt cache them this way. Only after I call the request normally for the Detail Screen, is that it actually caches as expected if I tried to re-enter the screen.
What can I do to precache multiple request at the beginning of the app

Mismatch between Chrome Task Manager CPU usage (100%) and Performance Profile (idle)

I have a webpage I'm trying to debug in Chrome v67.0.3396.62. Intermittently the page becomes unresponsive, and both Windows Task Manager and Chrome's built in Task Manager show 100% CPU usage [on a single core].
This problem does not happen in any reliable or reproducible way - I can go days without a problem, then have issues for hours and have to end the tab process in order to regain use of it every time the page loads.
I have somehow managed to capture a performance profile using Chrome's Dev tools performance tab during a time that this problem was occurring. However, the profile shows the process to be mostly idle.
What could cause 100% cpu usage that is not captured by the dev tools performance profiling?
(I have already poured over my own code for infinite loops/recursion, but haven't found anything suspect. I am using jquery, bootstrap and popper, but they're all being served from reputable CDNs and match their integrity hashes, so I'm at a loss how to debug any further. Any suggestions would be much appreciated.)

Chrome DevTools Network Waterfall - gaps between requests?

I've been doing some refactoring on a slow running web application, and managed to reduce the number of requests and the size of the downloads to help improve the situation. Now the loading time is consistently shorter. However, consistently before there was hardly any time elapsed before the last 2 requests. Now consistently there is a gap.
Q1: What do these 'gaps' indicate in Chrome Network view?
Q2: Looking at the screenshots, the DOMContentLoaded time vs. the overall Finish time, are there any conclusions I can draw that could help me optimise further?
Record the page load in the Performance panel. See Get Started With Analyzing Runtime Performance to get the gist of how to use the panel. Understanding the network bottleneck can also help get you oriented.
However, you'll want to press the Reload page button (like Sam does in the "understanding the network bottleneck" video) instead of the Record button to record the page load performance, as the "get started with analyzing runtime performance" instructs you to do.
Once you've got a recording, the Main section shows you all of the main thread activity that occurs while the page is loading. The Network section shows you all of the Network requests. You'll probably be able to visually verify that there's a bunch of JavaScript work going on during the gap that you're seeing in your screenshots.
If it's still not clear to you, post a screenshot of your Performance panel recording and I'll help you decode the results.

Volley DefaultRetryPolicy when Connectivity is Spotty

I am using Android's Volley to retrieve JSON files and images. Overall the performance is fantastic. I set a progress indicator before starting the request using
getSherlockActivity().setProgressBarIndeterminateVisibility(true);
and turn it off when the request is complete (in onResponse() or onErrorResponse().
My problem is on the train, especially in a tunnel, where connectivity is spotty. Frequently, the progressbar will persist for what seems like 8 or 10 seconds. When using volley, I am setting the DefaultRetryPolicy as follows:
jsObjRequest.setRetryPolicy(new DefaultRetryPolicy(2500, 2, 1.0f));
requestQueue.add(jsObjRequest);
Are there any suggestions to exit quicker when connectivity is poor?

importing, saving and displaying large data sets using background thread

I have followed Cocoa is my girl friend's tutorial here, which is based on a subclass of NSOperation to fetch and load big number of records in a background thread, but in my case I have several thousands of records which take 1-2 minutes of continuous loading from a remote web service. The app have web service proxy classes generated using SudzC. There is no memory leaks detected. The problem occurs after the app finishes loading and saving this huge number of records into sqlite database (using core data), I notice that this import/save operation consumes so much memory, i.e. after this operation finishes, I use the app features for couple minutes (opening table views, writing text, etc ...), then i will see a crash that happens due to low memory, if I didn't include the import/save operation the app works fine without any low memory crash!
does anybody have a clue for this problem ?
thanks in advance.