I have to send SFDC files to a third party application, via custom apex. My only concern is, if my file size is 40 MB, will it fail due to the heap size limit? If yes, what is the workaround?
Various Apex limits will get in the way of trying to push the data from Salesforce.
Instead, one approach is to signal to the third-party application that the file is ready to be moved via a HTTPS call (that supplies the URL) and have that third-party application pull the data from Salesforce. Or if the third-party application can't be programmed to do that, create an intermediary service on e.g. Heroku to do the work.