Category : memory-leaks

let g = document.getElementById(‘g’) let ch = 1; g.addEventListener(‘click’, () => { if (ch === 1) { g.src = “./aprilfool.jpg” ch = 0 } else if (ch === 0) { g.src = “./gift.jpg” ch = 1 } }) <!DOCTYPE html> <html lang=”en”> <head> <meta charset=”UTF-8″> <meta http-equiv=”X-UA-Compatible” content=”IE=edge”> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″> <link rel=”stylesheet” type=”text/css” ..

Read more

I am diagnosing a memory leak in a jQuery based single page application using the Chrome DevTools heap snapshot tool as described on https://developer.chrome.com/docs/devtools/memory-problems/#discover_detached_dom_tree_memory_leaks_with_heap_snapshots I have solved some issues this way, but I have now hit a roadblock where I can no longer determine what is keeping an object in memory. For example, for one ..

Read more

I currently have a Profile component acting as the Parent component; said component has the following code: const [profile, setProfile] = useState(null) const [posts, setPosts] = useState([]) useEffect(() => { getProfile(match.params.id) .then((result) => { // Set the user setProfile(result.payload.data) // Get posts by user getPosts(`?user=${match.params.id}`) .then((result) => { setPosts(result.payload.data) }) .catch((err) => { console.log(‘Posts error’ ..

Read more

I’m working on a project that uses a custom hook useRequest to fetch data from server. The implementation is const useRequest = ({ url }) => { const [isLoading, setIsLoading] = React.useState(true); const [error, setError] = React.useState(null); const [apiData, setApiData] = React.useState({}); React.useEffect(() => { const abortController = new AbortController(); fetch(url, { headers: headers, signal: ..

Read more